<?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: Infile data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499437#M132913</link>
    <description>&lt;P&gt;Maxim 2: read the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fdate = 09272018
%put &amp;amp;fdate.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;ERROR: Open code statement recursion detected.
27         %let fdate = 09272018
28         %put &amp;amp;fdate.;
&lt;/PRE&gt;
&lt;P&gt;Since the error happens right at the start, everything else is insignificant. Fix code from the top down.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, macro triggers are NEVER resolved in datalines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, dates like that should be ordered year-month-day, and not month-day-year or day-month-year, as you can't sort them properly in further processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the concatenating, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt; has given you the answer.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Sep 2018 11:07:15 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-09-27T11:07:15Z</dc:date>
    <item>
      <title>Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499432#M132908</link>
      <description>%let fdate = 09272018&lt;BR /&gt;%put &amp;amp;fdate.;&lt;BR /&gt;Data scores;&lt;BR /&gt;Input name $20.;&lt;BR /&gt;Datalines;&lt;BR /&gt;Shiv_&amp;amp;fdate.&lt;BR /&gt;Chara_&amp;amp;fdate.&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;I want the date to be populated at end of the name</description>
      <pubDate>Thu, 27 Sep 2018 10:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499432#M132908</guid>
      <dc:creator>shiv999</dc:creator>
      <dc:date>2018-09-27T10:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499434#M132910</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there is ";" missing in the %let statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And about adding the date, I would offer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fdate = 09272018;
%put &amp;amp;fdate.;
Data scores;
Input name $20.;
name = catx("_", name, "&amp;amp;fdate.");
Datalines;
Shiv
Chara
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 10:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499434#M132910</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2018-09-27T10:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499436#M132912</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;has mentioned you are missing a semi-colon.&amp;nbsp; Also you will need to follow:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/295.html" target="_blank"&gt;http://support.sas.com/kb/43/295.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get your macro variable resolved as natively macro does not resolve in datalines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which leads onto my question of why on earth woulf you want to do this as this is effectively the same, simpler:&lt;/P&gt;
&lt;PRE&gt;%let fdate = 09272018;
data scores;
  input name $20.;
  name=cats(name,"_&amp;amp;fdate.");
datalines;
Shiv
Chara
;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2018 11:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499436#M132912</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-27T11:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499437#M132913</link>
      <description>&lt;P&gt;Maxim 2: read the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fdate = 09272018
%put &amp;amp;fdate.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;ERROR: Open code statement recursion detected.
27         %let fdate = 09272018
28         %put &amp;amp;fdate.;
&lt;/PRE&gt;
&lt;P&gt;Since the error happens right at the start, everything else is insignificant. Fix code from the top down.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, macro triggers are NEVER resolved in datalines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, dates like that should be ordered year-month-day, and not month-day-year or day-month-year, as you can't sort them properly in further processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the concatenating, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt; has given you the answer.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 11:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499437#M132913</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-27T11:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499441#M132916</link>
      <description>Thanks Rw9 , I was not using data lines but using infiles . What would be the solution for infiles</description>
      <pubDate>Thu, 27 Sep 2018 11:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499441#M132916</guid>
      <dc:creator>shiv999</dc:creator>
      <dc:date>2018-09-27T11:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499450#M132919</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236597"&gt;@shiv999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks Rw9 , I was not using data lines but using infiles . What would be the solution for infiles&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Remove the datalines block and add the appropriate infile statement. The rest of the code stays as-is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having a datalines block lets the data step compiler implicitly add a&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile datalines;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;statement, if no explicit infile statement is found.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 12:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499450#M132919</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-27T12:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499451#M132920</link>
      <description>&lt;P&gt;Do you mean then you are reading from a filename which has that information in, if so:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "c:\tmp\shiv_&amp;amp;fdate..csv";
...
run;&lt;/PRE&gt;
&lt;P&gt;If not please show examples of what you mean.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 12:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499451#M132920</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-27T12:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499493#M132927</link>
      <description>Let me elobrate my issue .&lt;BR /&gt;In my infile data is like&lt;BR /&gt;In below form . I used translate and tranwrd functions . So here I want repalce this &amp;amp;fdate. With 09222018&lt;BR /&gt;&lt;BR /&gt;Shiva_&amp;amp;fdate._test&lt;BR /&gt;Kumar_test_&amp;amp;fdate.you&lt;BR /&gt;Faha_&amp;amp;fdate_.you&lt;BR /&gt;Hsjsb_&amp;amp;fdate._hjj&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Sep 2018 13:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499493#M132927</guid>
      <dc:creator>shiv999</dc:creator>
      <dc:date>2018-09-27T13:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499500#M132931</link>
      <description>&lt;P&gt;To resolve macro triggers in data (which is usually a very bad idea, anyway), use the resolve() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fdate=20180927;

data want;
infile datalines;
input name $30.;
name = resolve(name);
datalines;
Shiva_&amp;amp;fdate._test
Kumar_test_&amp;amp;fdate.you
Faha_&amp;amp;fdate._you
Hsjsb_&amp;amp;fdate._hjj
;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;         name

Shiva_20180927_test   
Kumar_test_20180927you
Faha_20180927_you     
Hsjsb_20180927_hjj    
&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2018 13:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499500#M132931</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-27T13:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499502#M132933</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you know that your date should be: 09222018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and you have external text file (let say: C:\my_file.txt)&amp;nbsp;&lt;/P&gt;&lt;P&gt;with contents:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Shiva_&amp;amp;fdate._test&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kumar_test_&amp;amp;fdate.you&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Faha_&amp;amp;fdate._.you&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hsjsb_&amp;amp;fdate._hjj&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;and you want to readin that file into dataset and resolve macrovariables, you should do:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let fdate = 09272018;
%put &amp;amp;fdate.;
Data scores;
infile "C:\my_file.txt";
Input name : $20.;
name = resolve(name);
run;&lt;/PRE&gt;&lt;P&gt;all the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 13:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499502#M132933</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2018-09-27T13:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499503#M132934</link>
      <description>Yes bad idea buts it's my infile . Yup great this worked thanks alot</description>
      <pubDate>Thu, 27 Sep 2018 13:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499503#M132934</guid>
      <dc:creator>shiv999</dc:creator>
      <dc:date>2018-09-27T13:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Infile data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499511#M132940</link>
      <description>&lt;P&gt;The question here really then is why do you have macro (which is SAS only) in a plain text file where there is no link to SAS, nor method of processing such a thing.&amp;nbsp; I am afraid you have a bad process there.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 13:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-data/m-p/499511#M132940</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-27T13:39:16Z</dc:date>
    </item>
  </channel>
</rss>

