<?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: Can you help me ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me/m-p/178951#M34199</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code looks like there may be confusion between the macro language and data step programming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to parse the information out of the automatic filename variable dfnvar the use do not use macro statements at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may be able to use this code to read the value of the date part from the file name into a SAS date variable which is much more flexible in the data step and no macro needed:&lt;/P&gt;&lt;P&gt;FileDate = input(scan(dfnvar,2,'._'),yymmdd8.);&lt;/P&gt;&lt;P&gt;month=month(filedate);&lt;/P&gt;&lt;P&gt;QRT = qtr(filedate);&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Aug 2014 18:27:59 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-08-28T18:27:59Z</dc:date>
    <item>
      <title>Can you help me ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me/m-p/178950#M34198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Dear All&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;I am trying to create a macro with wild card that can dynamically read a series of raw data files (txt data files). The raw data files have name (letters) with .txt extension followed by date_timestamp. The following samples represnt the raw data files. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;ZLGOPAR.txt.20140404_205224&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;VLSNHMONFCW.txt.20140404_212853&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;I have 50-60 raw data files like these.&amp;nbsp; I tried to write a read in macro but it is not working. &lt;/SPAN&gt;&lt;SPAN style="font-size: 14pt;"&gt;I have used filename = dfnVAR (in the inflie statement) whose length I want to use to&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 14pt;"&gt;extract Month, Year and FY etc as you can see below. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Please take a look at what I wrote and help me resolve this issue. I am not sure if my infile statement is correct. Anyway, the idea is to be able to read all the raw datafiles dynamically by the macro. I would be grateful to your kind assistance and support. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET Path = H:\STARS\Mar\FL;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET dfnLEN = LENGTH(dfnVAR);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET dfnSTART = dfnLEN – 15;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: red; font-size: 20pt;"&gt;%LET MONTH = substr(dfnVAR, dfnSTART + 5, 2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET FYread = substr(dfnVAR, dfnSTART + 3, 2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET FYint = input(FYread, 2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET MONTHint = input(MONTH, 2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;IF MONTHint &amp;gt; 9 THEN FYint = FYint + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET FYstr = put(FYint, hex2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: red; font-size: 20pt;"&gt;%LET FY = CAT(“FY”, FYstr);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;%LET QRT = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: red; font-size: 20pt;"&gt;%LET QRT_YR_FULL = CAT(“Q”, QRT, “FY20”, FYstr);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;%macro readindata(Table_In, Finalout, Month);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;data file1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "&amp;amp;Path\file*.txt" filename = dfnVAR eov = first_this_file end = done;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input ...................................................................................................&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;if _n_ = 1 or first_this_file then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Put 'Start reading ' dfnVAR=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;IF MONTHint &amp;lt; 4 THEN QRT = 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;ELSE IF MONTHint &amp;lt; 7 THEN QRT = 3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;ELSE IF MONTHint &amp;lt; 10 THEN QRT = 4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left; margin-top: 4.8pt; text-indent: 0in;"&gt;&lt;SPAN style="font-family: Calibri; color: black; font-size: 20pt;"&gt;ELSE QRT = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;%mend readindata;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;%readindata()&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2014 16:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me/m-p/178950#M34198</guid>
      <dc:creator>u_chandra</dc:creator>
      <dc:date>2014-08-28T16:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me/m-p/178951#M34199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code looks like there may be confusion between the macro language and data step programming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to parse the information out of the automatic filename variable dfnvar the use do not use macro statements at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may be able to use this code to read the value of the date part from the file name into a SAS date variable which is much more flexible in the data step and no macro needed:&lt;/P&gt;&lt;P&gt;FileDate = input(scan(dfnvar,2,'._'),yymmdd8.);&lt;/P&gt;&lt;P&gt;month=month(filedate);&lt;/P&gt;&lt;P&gt;QRT = qtr(filedate);&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2014 18:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me/m-p/178951#M34199</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-08-28T18:27:59Z</dc:date>
    </item>
  </channel>
</rss>

