

{"id":11179,"date":"2018-03-20T06:09:46","date_gmt":"2018-03-20T00:39:46","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=11179"},"modified":"2021-05-09T13:17:02","modified_gmt":"2021-05-09T07:47:02","slug":"sas-program-structure","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/","title":{"rendered":"SAS Program Structure &#8211; Steps Involved in a SAS Program"},"content":{"rendered":"<p>In our last SAS Programming\u00a0tutorial, we have seen <strong>SAS user interface<\/strong>\u00a0and today we will talk about SAS program structure, steps involved in program structure of SAS Programming: SAS data step, PROC Step in SAS.<\/p>\n<p>Lastly, we will see some basic differences between SAS DATA and SAS PROC in brief.<\/p>\n<p>Let&#8217;s now begin with the structure of SAS Program.<\/p>\n<h2>SAS Program Structure<\/h2>\n<p>Before you run an analysis, write a report, before you do anything with your data, SAS must be able to read your data. For data to be analyzed by SAS, it first has to be in the form of a dataset. <strong>SAS\u00a0DataSet <\/strong>is the organization of data values in a table in the form of rows and columns.<\/p>\n<p>The main components of a SAS program are the DATA step and the PROC step.<\/p>\n<p>Below is a diagrammatical representation of steps involved in the structure of the SAS Program.<\/p>\n<div id=\"attachment_11198\" style=\"width: 680px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/ps_flow_1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-11198\" class=\"wp-image-11198 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/ps_flow_1.jpg\" alt=\" SAS Program Structure\" width=\"670\" height=\"365\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/ps_flow_1.jpg 670w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/ps_flow_1-150x82.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/ps_flow_1-300x163.jpg 300w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/a><p id=\"caption-attachment-11198\" class=\"wp-caption-text\">Steps Involved &#8211; SAS Program Structure<\/p><\/div>\n<p>Here, is a simple program that converts kilometers to meters inside a SAS DATA step and prints the results in a SAS PROC step:<\/p>\n<p><strong>DATA distance;<\/strong><br \/>\n<strong>kilometers = 23;<\/strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;=====\u00a0 \u00a0DATA STEP<br \/>\n<strong>meters = 1000*kilometers;<\/strong><br \/>\n<strong>PROC PRINT DATA = distance;<\/strong><br \/>\n<strong>Run;\u00a0 \u00a0<\/strong> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;======\u00a0 PROC STEP<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/sas_syntax_style_standards.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-11200 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/sas_syntax_style_standards.png\" alt=\"SAS Program Structure\" width=\"660\" height=\"232\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/sas_syntax_style_standards.png 660w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/sas_syntax_style_standards-150x53.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/sas_syntax_style_standards-300x105.png 300w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>Let us examine each SAS component in detail.<\/p>\n<h3>i. SAS DATA Step<\/h3>\n<p>This step involves loading the required data set into SAS memory.<\/p>\n<p>A DATA step reads and modifies data and starts with the keyword DATA. This keyword is followed by a name that you make up for a SAS data set. The DATA step above produces a SAS data set named DISTANCE.<\/p>\n<p>The SAS DATA Step is used for the following purposes:<\/p>\n<ul>\n<li>Getting input data into a SAS dataset.<\/li>\n<li>Editing- checking for any errors in the data and correcting them.<\/li>\n<li>Creating new SAS data sets from existing ones by merging and updating the old data sets.<\/li>\n<li>Data manipulation such as updating, modifying or rearranging data in a SAS dataset.<\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">DATA data_set_name;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Name of the data set.\r\nINPUT var1,var2,var3;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 #Defines the variables in this data set.\r\nNEW_VAR;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0#Creates a new variable.\r\nLABEL;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0#Assign labels to variables.\r\nDATALINES;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 #Enters the data.\r\nRUN;<\/pre>\n<h3>ii. SAS PROC Step<\/h3>\n<p>The beginning of all procedures in SAS starts with a PROC statement in which the keyword PROC is followed by the name of the procedure (MOD, PRINT, <strong>Proc SORT<\/strong>, or <strong>Proc MEANS<\/strong>, for example).<\/p>\n<p>In this step, a SAS built-in procedure is invoked for analyzing the data. Just like the recipe is followed in a sequential manner, in SAS we use basically the same statements every time.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">PROC procedure_name options;\u00a0 \u00a0#The name of the proc.\r\nRUN;<\/pre>\n<h3>iii. SAS OUTPUT\u00a0 Step<\/h3>\n<p>An end of a step occurs when SAS comes across a new step which is marked by a DATA or PROC statement and a RUN statement. RUN statements tell SAS to run all the preceding lines. RUN statements, however, are not part of a DATA or PROC step.<\/p>\n<p>In the SAS program above, SAS comes to know that the SAS DATA step has ended when it comes to the PROC statement in the next line. The PROC step ends with a RUN statement, which means the program has ended.<\/p>\n<h2>Difference Between DATA Step and PROC Step<\/h2>\n<p>Here, are some basic differences between SAS DATA Step and PROC steps in SAS:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p style=\"text-align: center;\"><b>DATA step\u00a0 \u00a0<\/b><\/p>\n<\/td>\n<td>\n<p style=\"text-align: center;\"><b> \u00a0\u00a0\u00a0\u00a0PROC step<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">They always Begin with DATA statements \u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">They always begin with PROC statements<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Read and modify data \u00a0\u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Perform specific analysis on data<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Create a SAS data set<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Produce results or report<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Summary<\/h2>\n<p>Hence, although a typical SAS program starts with a SAS DATA step to input data and then passes that data to a PROC step in SAS, it is not a hard and fast rule.<\/p>\n<p>Like you can stack building blocks in any order, you can arrange DATA and PROC steps in any order. The SAS program has the flexibility to contain either only DATA steps or only PROC steps.<\/p>\n<p>Furthermore, if you have any query, feel free to ask in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last SAS Programming\u00a0tutorial, we have seen SAS user interface\u00a0and today we will talk about SAS program structure, steps involved in program structure of SAS Programming: SAS data step, PROC Step in SAS.&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":11197,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[19279,12206,12217,13945],"class_list":["post-11179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sas","tag-sas-program-components","tag-sas-program-structure","tag-sas-programming-tutorial","tag-structure-of-sas-program"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SAS Program Structure - Steps Involved in a SAS Program - DataFlair<\/title>\n<meta name=\"description\" content=\"SAS program structure involves SAS DATA step, SAS PROC Step and SAS Output step, and difference between SAS DATA step &amp; SAS PROC step.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/sas-program-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SAS Program Structure - Steps Involved in a SAS Program - DataFlair\" \/>\n<meta property=\"og:description\" content=\"SAS program structure involves SAS DATA step, SAS PROC Step and SAS Output step, and difference between SAS DATA step &amp; SAS PROC step.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/sas-program-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-20T00:39:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-09T07:47:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Program-Structure-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SAS Program Structure - Steps Involved in a SAS Program - DataFlair","description":"SAS program structure involves SAS DATA step, SAS PROC Step and SAS Output step, and difference between SAS DATA step & SAS PROC step.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/","og_locale":"en_US","og_type":"article","og_title":"SAS Program Structure - Steps Involved in a SAS Program - DataFlair","og_description":"SAS program structure involves SAS DATA step, SAS PROC Step and SAS Output step, and difference between SAS DATA step & SAS PROC step.","og_url":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-03-20T00:39:46+00:00","article_modified_time":"2021-05-09T07:47:02+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Program-Structure-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"SAS Program Structure &#8211; Steps Involved in a SAS Program","datePublished":"2018-03-20T00:39:46+00:00","dateModified":"2021-05-09T07:47:02+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/"},"wordCount":641,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Program-Structure-01.jpg","keywords":["SAS Program Components","SAS Program Structure","SAS Programming Tutorial","Structure of SAS Program"],"articleSection":["SAS Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/sas-program-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/","url":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/","name":"SAS Program Structure - Steps Involved in a SAS Program - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Program-Structure-01.jpg","datePublished":"2018-03-20T00:39:46+00:00","dateModified":"2021-05-09T07:47:02+00:00","description":"SAS program structure involves SAS DATA step, SAS PROC Step and SAS Output step, and difference between SAS DATA step & SAS PROC step.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/sas-program-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Program-Structure-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Program-Structure-01.jpg","width":1200,"height":628,"caption":"SAS Program Structure"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/sas-program-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"SAS Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/sas\/"},{"@type":"ListItem","position":3,"name":"SAS Program Structure &#8211; Steps Involved in a SAS Program"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=11179"}],"version-history":[{"count":10,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11179\/revisions"}],"predecessor-version":[{"id":94015,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11179\/revisions\/94015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/11197"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=11179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=11179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=11179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}