[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-693583-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-693583-en":130,"doc-similar-693583":158},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","an-introduction-to-sql-in-sas","An Introduction to SQL in SAS®","","SQL is one of the built-in languages of the SAS® System. With PROC SQL, SAS users gain a powerful tool for data manipulation and query. The tutorial introduces the core structure of a SQL query—SELECT, FROM, ON, WHERE, GROUP BY, HAVING, and ORDER BY—showing how clause order supports selecting columns, subsetting rows, joining tables, summarizing information, filtering summarized results, and sorting output. It also explains PROC SQL syntax and how query results can be displayed or written to ODS outputs.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/an-introduction-to-sql-in-sas/693583/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/an-introduction-to-sql-in-sas/693583.png","ImageObject",300,407,{"name":42,"@type":43},"jay","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-12","2026-11-10",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What are the main SQL keywords covered in this tutorial?","Question",{"text":62,"@type":63},"The tutorial focuses on SELECT, FROM, ON, WHERE, GROUP BY, HAVING, and ORDER BY, and notes that these cover the vast majority of queries.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"Which clauses are required to form a valid SQL query in this guide?",{"text":67,"@type":63},"SELECT is required for a query, and the FROM clause is the only other required clause; other keywords appear as optional clauses.",{"name":69,"@type":60,"acceptedAnswer":70},"How is PROC SQL syntax executed, and where are results displayed?",{"text":71,"@type":63},"A full SELECT…FROM query is treated as one statement ending with a single semicolon, executed as soon as it completes; results display in SAS output destinations such as the output window and any open ODS targets like HTML and PDF.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},693583,1794290693,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":79,"read_time":144,"preview_page_count":30,"preview_urls":145},3985747858866,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","SUGI 30 Tutorials  \nPaper 257-30  \nAn Introduction to SQL in SAS®  \nPete Lund  \nLooking Glass Analytics, Olympia WA  \nABSTRACT  \nSQL is one of the many languages built into the SAS® System. Using PROC SQL, the SAS user has access to a powerful data manipulation and query tool. Topics covered will include selecting, subsetting, sorting and grouping data--all without use of DATA step code or any procedures other than PROC SQL.  \nTHE STRUCTURE OF A SQL QUERY  \nSQL is a language build on a very small number of keywords:  \n• SELECT  \n• FROM  \n• ON  \n• WHERE  \n• GROUP BY  \n• HAVING  \n• ORDER BY  \ncolumns (variables) that you want  \ntables (datasets) that you want  \njoin conditions that must be met row (observation) conditions that must be met summarize by these columns  \nsummary conditions that must be met  \nsort by these columns  \nFor the vast majority of queries that you run, the seven keywords listed above are all you’ll need to know. There are also a few functions and operators specific to SQL that can be used in conjunction with the keywords above.  \nSELECT is a statement and is required for a query. All the other keywords are clauses of the SELECT statement. The FROM clause is the only one that is required. The clauses are always ordered as in the list above and each clause can appear, at most, once in a query.  \nThe nice thing about SQL is that, because there are so few keywords to learn, you can cover a great deal in a short paper. So, let’s get on with the learning!  \nAs we go through the paper you will see how much sense the ordering of the SQL clauses makes.  \nYou’re telling the program what columns you want to SELECT and FROM which table(s) they come. If there is more than one table involved in the query you need to say ON what columns the rows should be merged together. Also, you might only want rows WHERE certain conditions are met.  \nOnce you’ve specified all the columns and rows that should be selected, there may be a reason to GROUP BY one or more of your columns to get a summary of information. There may be a need to only keep rows in the result set HAVING certain values of the summarized columns.  \nFinally, there is often a need to ORDER BY one or more of your columns to get the result sorted the way you want. Simply thinking this through as we go through the paper will help you remember the sequence of clauses. CHOOSING YOUR COLUMNS-THE SELECT STATEMENT  \nThe first step in getting the data that you want is selecting the columns (variables) . To do this, use the SELECT statement:  \nselect BookingDate,  \nReleaseDate,  \nReleaseCode  \nSUGI 30 Tutorials  \nList as many columns as needed, separated by commas. There are a number of options that can go along with columns listed in a SELECT statement. We’ll look at those in detail shortly.  \nWe’ll also see that new columns can be created, arithmetic and logical operations can be performed and summary functions can be applied. In short, SELECT is a very versatile and powerful statement.  \nCHOOSING YOUR TABLE – THE FROM CLAUSE  \nThe next step in getting that data that you want is specifying the table (dataset) . To do this, use the FROM clause:  \nselect BookingDate,  \nReleaseDate,  \nReleaseCode  \nfrom SASclass .Bookings  \nThe table naming conventions in the FROM clause are the normal SAS dataset naming conventions, since we are referencing a SAS dataset. You can use single-level names for temporary datasets or two-level names for permanent datasets.  \nThese two components (SELECT and FROM) are all that is required for a valid query. In other words, the query above is a complete and valid SQL query. There are just a couple additions we need to make for SAS to be able to execute it.  \nUSING SQL IN SAS  \nNow that we know enough SQL to actually do something “legal” (SELECT and FROM), let’s see how we would use SQL in SAS: PROC SQL.  \nproc sql;  \nselect BookingDate,  \nReleaseDate,  \nReleaseCode  \nfrom SASclass .Bookings;  \nquit;  \nThere are a number of things to notice about the ","cbCaioDeC6Q2EptT","https://ap.wps.com/l/cbCaioDeC6Q2EptT","pdf",1022521,22,"English","# THE STRUCTURE OF A SQL QUERY\n## CHOOSING YOUR COLUMNS-THE SELECT STATEMENT\n## CHOOSING YOUR TABLE – THE FROM CLAUSE\n# USING SQL IN SAS\n## WHAT TO DO WITH THE RESULTS","[{\"question\":\"What are the main SQL keywords covered in this tutorial?\",\"answer\":\"The tutorial focuses on SELECT, FROM, ON, WHERE, GROUP BY, HAVING, and ORDER BY, and notes that these cover the vast majority of queries.\"},{\"question\":\"Which clauses are required to form a valid SQL query in this guide?\",\"answer\":\"SELECT is required for a query, and the FROM clause is the only other required clause; other keywords appear as optional clauses.\"},{\"question\":\"How is PROC SQL syntax executed, and where are results displayed?\",\"answer\":\"A full SELECT…FROM query is treated as one statement ending with a single semicolon, executed as soon as it completes; results display in SAS output destinations such as the output window and any open ODS targets like HTML and PDF.\"}]","An Introduction to SQL in SAS® | PDF",55,[146,150,154],{"page_no":22,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-10/54df5df76ec62d35053eef8d992bd6b9.webp",983,1272,{"page_no":26,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-10/ccfef3dc6bc7439eb50e13ebbcea1c4b.webp",982,1270,{"page_no":30,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-10/d15415b1179b8cc70c36222d55e49ac8.webp",981,1269,{"list":159,"token":11},[160,166,172,178,185,191,197,203,209,215],{"doc_id":161,"doc_title":162,"file_type":137,"home_preview_img_url":163,"slug":164,"view_count":105,"category_name":29,"create_tm":165},656119,"EMS SQL Query - Powerful tool for advanced SQL query building","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229974785307/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=AbZLeyaQ8S%2F4613uVgeu6CARRHw%3D","ems-sql-query-powerful-tool-for-advanced-sql-query-building",1792966480,{"doc_id":167,"doc_title":168,"file_type":137,"home_preview_img_url":169,"slug":170,"view_count":33,"category_name":29,"create_tm":171},692258,"SQL - Quick Guide - SQL Basics","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230003050421/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=pywje9oFjQLx%2Bom%2Fa6uNi4yX5ks%3D","sql-quick-guide-sql-basics",1794187831,{"doc_id":173,"doc_title":174,"file_type":137,"home_preview_img_url":175,"slug":176,"view_count":101,"category_name":29,"create_tm":177},656121,"SAS Global Forum 2012 Programming - Paper 251-2012 - Exploring DATA Step Merges and PROC SQL Joins","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975300872/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=WY6Fp%2BivCiaNqW1Rfdl3KpMoUtA%3D","sas-global-forum-2012-programming-paper-251-2012-exploring-data-step-merges-and-proc-sql-joins",1792966524,{"doc_id":179,"doc_title":180,"file_type":137,"home_preview_img_url":181,"slug":182,"view_count":183,"category_name":29,"create_tm":184},290696,"The Little SAS Book - Fifth Edition - Contents","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229903739494/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=jfidN9FefLMvM0STzEPmidSk56Y%3D","the-little-sas-book-fifth-edition-contents",15,1789642381,{"doc_id":186,"doc_title":187,"file_type":137,"home_preview_img_url":188,"slug":189,"view_count":33,"category_name":29,"create_tm":190},689536,"NetSuite SuiteQL Guide - Custom Fields, Joins & Queries","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001713856/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=188ivLIpCpaudXyUMoifUs6LY8M%3D","netsuite-suiteql-guide-custom-fields-joins-queries",1794113303,{"doc_id":192,"doc_title":193,"file_type":137,"home_preview_img_url":194,"slug":195,"view_count":123,"category_name":29,"create_tm":196},656140,"Oracle SQL by Example - Table of Contents","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975301629/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=RU9Qk3%2BZAKi6ctlP9SmR7bWNnIM%3D","oracle-sql-by-example-table-of-contents",1792966695,{"doc_id":198,"doc_title":199,"file_type":137,"home_preview_img_url":200,"slug":201,"view_count":110,"category_name":29,"create_tm":202},656142,"01-HoffmanSQL - Introduction to Structured Query Language - Version 4.66","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229974785935/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=AbarBp50UZapS5xZn3wxxhT63kI%3D","01-hoffmansql-introduction-to-structured-query-language-version-466",1792966698,{"doc_id":204,"doc_title":205,"file_type":137,"home_preview_img_url":206,"slug":207,"view_count":33,"category_name":29,"create_tm":208},697965,"Arrays Made Easy - An Introduction to Arrays and Array Processing - SUGI 30 Tutorials","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146275/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=xWGprVgmJyW4uMcE%2Fr38u%2Bf96to%3D","arrays-made-easy-an-introduction-to-arrays-and-array-processing-sugi-30-tutorials",1794446535,{"doc_id":210,"doc_title":211,"file_type":137,"home_preview_img_url":212,"slug":213,"view_count":105,"category_name":29,"create_tm":214},656138,"Outer Joins - What Is an OUTER JOIN? - LEFT/RIGHT and FULL OUTER JOIN","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229974785907/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=Bh702%2FSEZZsu%2Fkg8Q7NLQ5QnelA%3D","outer-joins-what-is-an-outer-join-leftright-and-full-outer-join",1792966689,{"doc_id":216,"doc_title":217,"file_type":137,"home_preview_img_url":218,"slug":219,"view_count":22,"category_name":29,"create_tm":220},763509,"SQL Practice 1 - Single Table Aggregation and Group By - Database Queries and Exercises","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230047479663/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=OInLR2NbI7goMRPgaa2f%2B1GvTvo%3D","sql-practice-1-single-table-aggregation-and-group-by-database-queries-and-exercises",1796034078]