<?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: Is there a way to instantly resolve macro variable created in a data step in the same data step? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534720#M146774</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Here's what the customer file looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID:&amp;nbsp; &amp;nbsp;'100001'&lt;/P&gt;
&lt;P&gt;Firstname:&amp;nbsp; 'Lonzo'&lt;/P&gt;
&lt;P&gt;Lastname:&amp;nbsp; &amp;nbsp;'Ball'&lt;/P&gt;
&lt;P&gt;There are 3 spaces between the labels and the values. Input dataset is same as mentioned in my previous post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are your files really that simple?&lt;/P&gt;
&lt;P&gt;Why not just use named input?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   length id $10 firstname lastname $30 ;
   input @'ID:' id @'Firstname:' firstname @'Lastname:' lastname ;
cards;
ID:   '100001'
Firstname:  'Lonzo'
Lastname:   'Ball'
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really want to use GREP then you can use FILEVAR= option with the PIPE engine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Feb 2019 04:46:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-02-12T04:46:17Z</dc:date>
    <item>
      <title>Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534457#M146657</link>
      <description>&lt;P&gt;Background is that I need to use filename command to execute grep and use the result as input.&lt;/P&gt;&lt;P&gt;Here is my input data set named&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;firstname   lastname   filename
&amp;lt;blank&amp;gt;     &amp;lt;blank&amp;gt;    cus_01.txt
&amp;lt;blank&amp;gt;     &amp;lt;blank&amp;gt;    cus_02.txt&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Filename values are actual files which I need to grep because I need certain string inside those files to fill up the firstname and lastname&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data work.test;
   set work.test;
   call symputx('file', filename);
   filename fname pipe "grep ""Firstname"" &amp;lt;path&amp;gt;/&amp;amp;file.";
   filename lname pipe "grep ""Lastname"" &amp;lt;path&amp;gt;/&amp;amp;file.";
   infile fname;
   input firstname;
   infile lname;
   input lastname; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, macro variables created inside a data step can't be used until after the data step procedure is completed. So, that means, &amp;amp;file. can't be resolved and can't be used in filename.&lt;/P&gt;&lt;P&gt;Is there a way to for resolve the macro variable?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 13:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534457#M146657</guid>
      <dc:creator>rcsutherland</dc:creator>
      <dc:date>2019-02-11T13:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534464#M146658</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;However, macro variables created inside a data step can't be used until after the data step procedure is completed.&amp;nbsp;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can counter that using &lt;STRONG&gt;Resolve function&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000210258.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000210258.htm&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 14:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534464#M146658</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T14:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534473#M146661</link>
      <description>&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'filename fname pipe "grep ""Firstname"" &amp;lt;path&amp;gt;/'||resolve('&amp;amp;file.');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Feb 2019 14:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534473#M146661</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T14:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534521#M146679</link>
      <description>&lt;P&gt;Given that you know the folder, and given that a variable FILENAME contains the name of file that you want to read, you should be able to eliminate the macro language entirely.&amp;nbsp; Note that the FILEVAR= option on the INFILE statement lets you specify as a variable the path to the file that should be read.&amp;nbsp; Here's some detail:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/techsup/technote/ts581.pdf" target="_blank"&gt;http://support.sas.com/techsup/technote/ts581.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 16:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534521#M146679</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-11T16:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534538#M146684</link>
      <description>&lt;P&gt;I'm new to SAS, can you explain how can FILEVAR help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking into this code from the example you gave:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename indata pipe ’ls -1 /dept/tsd/dataread/files’;
data one;
length fil2read $40 lname $20 fname $20 state $2;
infile indata truncover;
input f2r $20.;
fil2read=’/dept/tsd/dataread/files/’||f2r;
infile dummy filevar=fil2read end=done;
do while(not done);
 input lname : $20. fname : $20. state $ phone;
 output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From what I understand, filename command will store all files present in&amp;nbsp;&lt;CODE class=" language-sas"&gt;/dept/tsd/dataread/files &lt;/CODE&gt;to indata. Then first INFILE will input indata using input f2r. Then fileread variable will just concatenate the path and the name of the files (f2r).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where can I insert my grep command here? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 17:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534538#M146684</guid>
      <dc:creator>rcsutherland</dc:creator>
      <dc:date>2019-02-11T17:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534545#M146687</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesn't seem to work, it doesn't recognize the resolve nor the || in the code. Here's what I did:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fname pipe "grep ""Firstname"" &amp;amp;path./" || resolve('&amp;amp;file.');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Invalid Option Name | |&lt;/P&gt;&lt;P&gt;Invalid Option Name file&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 11 Feb 2019 17:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534545#M146687</guid>
      <dc:creator>rcsutherland</dc:creator>
      <dc:date>2019-02-11T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534548#M146690</link>
      <description>&lt;P&gt;SInce you already have a list of files in a SAS data set named TEST, your program becomes much simpler, along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length f2r $ 70 lname $ 20 fname $ 20 state $ 2;
set test;
f2r = '/dept/tsd/dataread/files/' || filename;
infile dummy filevar=f2r end=done;
do until (done);
   input lname fname state phone;
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Obviously, I don't have your data to test with.&amp;nbsp; But this should be a step in the right direction.&amp;nbsp; You'll have to be the one to test it and see how close we're getting to the result you want.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 17:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534548#M146690</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-11T17:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534594#M146709</link>
      <description>&lt;P&gt;Hi rcsutherland&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know what your customer files actually look like, but I suppose you have a good reason for wanting to extract name lines using GREP instead of reading the files and extracting the names in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not easy to get your code to work as intended. So I suggest another approach. It is just an example to show the idea, and the grep result is probably more difficult to read in real life.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Test input istwo files in folder /sasdata/user/sasbatch/erlu names cus_01 and cus_o2 with content like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Firstname Svend&lt;BR /&gt;Lastname Olsen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First step is to use grep to extract all first and last names from all files in the directory. The output from grep is 4 lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/sasdata/user/sasbatch/erlu/cus_01:Firstname Svend&lt;BR /&gt;/sasdata/user/sasbatch/erlu/cus_01:Lastname Olsen&lt;BR /&gt;/sasdata/user/sasbatch/erlu/cus_02:Firstname Erik&lt;BR /&gt;/sasdata/user/sasbatch/erlu/cus_02:Lastname Larsen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename lfname pipe "grep 'Firstname\|Lastname' /sasdata/user/sasbatch/erlu/*";
data work.grepresult;
	length filename $100 type $10 name $60;
	infile lfname;
	input;
	filename = scan(_infile_,1,':');
	type = scan(_infile_,2,': ');
	name = scan(_infile_,3,': ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Data from this step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fromgrep.gif" style="width: 562px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27060iB4C447AC1A50A0CF/image-size/large?v=v2&amp;amp;px=999" role="button" title="fromgrep.gif" alt="fromgrep.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next step is to make one record pr. file with Firstname and lastname. I use a full join to handle missing values in a simple way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table work.custnames as
		select 
			a.name as Firstname,
			b.name as Lastname,
			coalesce(a.filename,b.filename) as filename
	from work.grepresult (where=(type = 'Firstname')) as a
	full outer join work.grepresult (where=(type = 'Lastname')) as b
	on a.filename = b.filename;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result looks like your test table with names filled in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="result.gif" style="width: 488px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27061iF20B17F2A8CBAC40/image-size/large?v=v2&amp;amp;px=999" role="button" title="result.gif" alt="result.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you actual data has other variables, You could join on filename.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 19:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534594#M146709</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-02-11T19:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534599#M146712</link>
      <description>&lt;P&gt;FILEVAR helps you because it allows you to arbitrarily point an INFILE or FILE statement to a value defined as a data step variable (as opposed to a string in code).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your grep command doesn't really make sense to me, because it seems like you're not using SAS the way it's intended to be used.&amp;nbsp; SAS is quote good at reading from files/strings/etc., and doesn't need help from grep; in fact you can use regular expressions if you wish ('perl regular expressions SAS' would be a good search, or, 'PRXMATCH' etc. functions).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a filename in a variable, and want to read some information from that file, then all you need is (assuming 'have' is your dataset with filenames, stored in a variable named 'file_name_variable').&amp;nbsp; 'a' in the infile statement is a meaningless token that has to be there but doesn't do anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; set have;
&amp;nbsp; infile a filevar=file_name_variable;
&amp;nbsp; input lname $ fname $;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming they're in that order (last name then first name, space separated).&amp;nbsp; I imagine they're not space separated, but you haven't clarified that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if this is a JSON file, you have some better ways to do this (including using the&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sasdummy/2016/12/02/json-libname-engine-sas/" target="_blank" rel="noopener"&gt;JSON Libname&lt;/A&gt; ), but one way is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; set have;
&amp;nbsp; infile a filevar=file_name_variable;
&amp;nbsp; input @'"FirstName":' fname $
           @'"LastName":' lname $
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This basically uses&amp;nbsp;@-string matching to find the string that matches '"FirstName":'&amp;nbsp; and then reads the characters after that into fname.&amp;nbsp; You might need to do further processing to make sure it terminates at the next " character, or read the file as quotation-delimited, or something else, but it's possible.&amp;nbsp; Do an internet search on "SAS JSON read" and you'll get a lot of results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if you have a more complex question - such as, those files don't necessarily have 'first name' and 'last name' in a consistent order - you certainly could use a regular expression to solve your problem (again, you probably don't need to, but who knows).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
&amp;nbsp; set have;
&amp;nbsp; infile a filevar=file_name_var;
&amp;nbsp; input&amp;nbsp;@;
&amp;nbsp; _prx_fname = prxparse('~"FirstName":(".*")~ios');
&amp;nbsp; _prx_lname = prxparse('~"LastName":(".*")~ios');
&amp;nbsp; if prxmatch(_prx_fname,_infile_) then&amp;nbsp;
&amp;nbsp; &amp;nbsp; fname = prxposn(_prx_fname,1,_infile_);
&amp;nbsp; if prxmatch(_prx_lname,_infile_) then&amp;nbsp;
&amp;nbsp; &amp;nbsp; lname = prxposn(_prx_lname,1,_infile);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, defining two regexps (one for each of fname/lname), then using PRXMATCH to test if they return a match, and if so, then using PRXPOSN to return the value from the parentheses (capture buffer).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming in the latter that this is a JSON file, hence the quotation marks; you'll need to make the right regexp for your data here (and I didn't test this, so my PRX may be a bit rusty, but if it doesn't work feel free to come back with your code.)&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 19:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534599#M146712</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2019-02-11T19:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534712#M146768</link>
      <description>&lt;P&gt;Thank you all! FILEVAR is so powerful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My only problem now is how to search for the required string on each text files customer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what the customer file looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ID:&amp;nbsp; &amp;nbsp;'100001'&lt;/P&gt;&lt;P&gt;Firstname:&amp;nbsp; 'Lonzo'&lt;/P&gt;&lt;P&gt;Lastname:&amp;nbsp; &amp;nbsp;'Ball'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;There are 3 spaces between the labels and the values. Input dataset is same as mentioned in my previous post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname temp "&amp;lt;path&amp;gt;";
%let tmp = &amp;lt;path&amp;gt;;

data temp._output;
 set temp._input;
    length path f2r $500.;
    path = symget('tmp')
    f2r = cats(path,file);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;OUTPUT:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Firstname&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Lastname&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;File&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Path&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F2R&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cus_01.txt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;path&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;path&amp;gt;/cus_01.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cus_02.txt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;path&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;path&amp;gt;/cus_02.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 12 Feb 2019 03:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534712#M146768</guid>
      <dc:creator>rcsutherland</dc:creator>
      <dc:date>2019-02-12T03:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534713#M146769</link>
      <description>Hi ErikLund_Jensen,&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your input. I will use filevar because it's more easier. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 12 Feb 2019 03:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534713#M146769</guid>
      <dc:creator>rcsutherland</dc:creator>
      <dc:date>2019-02-12T03:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534720#M146774</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Here's what the customer file looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID:&amp;nbsp; &amp;nbsp;'100001'&lt;/P&gt;
&lt;P&gt;Firstname:&amp;nbsp; 'Lonzo'&lt;/P&gt;
&lt;P&gt;Lastname:&amp;nbsp; &amp;nbsp;'Ball'&lt;/P&gt;
&lt;P&gt;There are 3 spaces between the labels and the values. Input dataset is same as mentioned in my previous post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are your files really that simple?&lt;/P&gt;
&lt;P&gt;Why not just use named input?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   length id $10 firstname lastname $30 ;
   input @'ID:' id @'Firstname:' firstname @'Lastname:' lastname ;
cards;
ID:   '100001'
Firstname:  'Lonzo'
Lastname:   'Ball'
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really want to use GREP then you can use FILEVAR= option with the PIPE engine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 04:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534720#M146774</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-12T04:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to instantly resolve macro variable created in a data step in the same data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534722#M146776</link>
      <description>&lt;P&gt;I cannot use cards. My customer files are really like that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm no forcing to use grep, I'm just asking what other search function I could use when INFILE opened my textfiles during runtime. I need to search to get the string beside "Firstname" and "Lastname"&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 05:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-instantly-resolve-macro-variable-created-in-a/m-p/534722#M146776</guid>
      <dc:creator>rcsutherland</dc:creator>
      <dc:date>2019-02-12T05:58:12Z</dc:date>
    </item>
  </channel>
</rss>

