<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need to understand the logic of the SAS script in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834465#M329908</link>
    <description>&lt;P&gt;Honestly, I think this code is useless gibberish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It defines a macro named PULL_RPAD that has three arguments:&amp;nbsp;&lt;SPAN&gt;start_date, end_date, data_num. The arguments&amp;nbsp;start_date and end_date don't appear to be used anywhere, which is why I say it is gibberish.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then macro run_loop is created which loops through months which creates values of in1 in2 in3 that are used as arguments to PULL_RPAD, and in1 and in2 are ignored by PULL_RPAD.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course, the code could be modified to do something useful, but I think I'll stop there.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Sep 2022 13:15:13 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-09-21T13:15:13Z</dc:date>
    <item>
      <title>Need to understand the logic of the SAS script</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834440#M329902</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a new SAS learner and have taken the initiative to learn SAS. Could you please give me an idea about the below SAS code? What exactly is this code doing ? what will be achieved thought this code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro pull_rpad(start_date, end_date, data_num);&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to teradata ( tdpid=dwprod user=&amp;amp;tduser. pass=&amp;amp;tdpwd.);&lt;BR /&gt;create table Exchange_&amp;amp;data_num. as&lt;BR /&gt;select * from connection to teradata&lt;BR /&gt;(select * from table&lt;/P&gt;&lt;P&gt;);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc SQL;&lt;BR /&gt;select (strip(name)) into :vars separated by '|' from vars&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set Exchange_&amp;amp;data_num.;&lt;/P&gt;&lt;P&gt;file "/prd/sau20/Dave/Exchange_&amp;amp;data_num..txt" dsd dlm='|';&lt;BR /&gt;if _n_ = 1 then put "&amp;amp;vars";&lt;/P&gt;&lt;P&gt;%let dsid = %sysfunc(open(vars));&lt;BR /&gt;%let nobs = %sysfunc(attrn(&amp;amp;dsid,nlobs));&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%do i=1 %to &amp;amp;nobs;&lt;BR /&gt;%let rc = %sysfunc(fetchobs(&amp;amp;dsid,&amp;amp;i));&lt;BR /&gt;%let vName = %sysfunc(getvarc(&amp;amp;dsid,1));&lt;BR /&gt;%let vType = %sysfunc(getvarn(&amp;amp;dsid,2));&lt;BR /&gt;%put &amp;amp;=vName &amp;amp;=vType;&lt;/P&gt;&lt;P&gt;%if &amp;amp;vType = 2 %then %do;&lt;BR /&gt;put (&amp;amp;vName) (~) @;&lt;BR /&gt;%end;&lt;BR /&gt;%else %if &amp;amp;vType = 1 %then %do;&lt;BR /&gt;put &amp;amp;vName @;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%if &amp;amp;i = &amp;amp;nobs %then %do;&lt;BR /&gt;put ;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%let dsid = %sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;%mend ;&lt;/P&gt;&lt;P&gt;%macro run_loop();&lt;BR /&gt;%let begin_date = '01SEP2017'd;&lt;BR /&gt;%let ii = 0;&lt;BR /&gt;%do ii = 0 %to 30;&lt;BR /&gt;data a;&lt;BR /&gt;in1 = put(intnx('month',&amp;amp;begin_date,&amp;amp;ii,'b'),yymmdd10.);&lt;BR /&gt;in2 = put(intnx('month',&amp;amp;begin_date,&amp;amp;ii,'e'),yymmdd10.);&lt;BR /&gt;in3 = year(intnx('month',&amp;amp;begin_date,&amp;amp;ii,'b'))*100+month(intnx('month',&amp;amp;begin_date,&amp;amp;ii,'b'));&lt;BR /&gt;call symput('in1',in1);&lt;BR /&gt;call symput('in2',in2);&lt;BR /&gt;call symput('in3',in3);&lt;BR /&gt;run;&lt;BR /&gt;%pull_rpad (&amp;amp;in1,&amp;amp;in2,&amp;amp;in3);&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%run_loop();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 10:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834440#M329902</guid>
      <dc:creator>Amoljadhav123</dc:creator>
      <dc:date>2022-09-21T10:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need to understand the logic of the SAS script</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834465#M329908</link>
      <description>&lt;P&gt;Honestly, I think this code is useless gibberish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It defines a macro named PULL_RPAD that has three arguments:&amp;nbsp;&lt;SPAN&gt;start_date, end_date, data_num. The arguments&amp;nbsp;start_date and end_date don't appear to be used anywhere, which is why I say it is gibberish.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then macro run_loop is created which loops through months which creates values of in1 in2 in3 that are used as arguments to PULL_RPAD, and in1 and in2 are ignored by PULL_RPAD.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course, the code could be modified to do something useful, but I think I'll stop there.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 13:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834465#M329908</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-21T13:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need to understand the logic of the SAS script</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834471#M329910</link>
      <description>&lt;P&gt;It seems to be generating pipe delimited text files.&lt;/P&gt;
&lt;P&gt;The main complexity seems to be around figuring out which variables are character so it can decide whether or not to use the ~ modifier on the PUT statement to force SAS to add quotes around values that do not need to be quoted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should ask yourself if you really need the extra quotes.&amp;nbsp; You might even look at PROC EXPORT or ODS CSV to see if they already add the extra quotes.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 13:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/834471#M329910</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-21T13:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need to understand the logic of the SAS script</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/835528#M330321</link>
      <description>Thank you Sir!!</description>
      <pubDate>Wed, 28 Sep 2022 06:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-understand-the-logic-of-the-SAS-script/m-p/835528#M330321</guid>
      <dc:creator>Amoljadhav123</dc:creator>
      <dc:date>2022-09-28T06:30:27Z</dc:date>
    </item>
  </channel>
</rss>

