<?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: create macro variables for list of observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71617#M20670</link>
    <description>This work can be also done with the SYMPUT CALL in a data step:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
	input var1 $ @@;&lt;BR /&gt;
cards;&lt;BR /&gt;
a b c d e f g&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	set have;&lt;BR /&gt;
	call symput ("name"||strip(_n_),var1);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%put _global_;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Yuewei</description>
    <pubDate>Wed, 16 Sep 2009 06:18:52 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-09-16T06:18:52Z</dc:date>
    <item>
      <title>create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71610#M20663</link>
      <description>hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a data set with one column which looks like this&lt;BR /&gt;
&lt;BR /&gt;
VAR1&lt;BR /&gt;
a&lt;BR /&gt;
b&lt;BR /&gt;
c&lt;BR /&gt;
d&lt;BR /&gt;
e&lt;BR /&gt;
.&lt;BR /&gt;
k&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I need to create macro variables for each observation, like:&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;name1 = a&lt;BR /&gt;
&amp;amp;name2 = b&lt;BR /&gt;
..&lt;BR /&gt;
&lt;BR /&gt;
Can you tell me how can i do that?</description>
      <pubDate>Tue, 15 Sep 2009 16:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71610#M20663</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-15T16:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71611#M20664</link>
      <description>Using PROC SQL, you can use the SELECT &lt;VARNAME&gt; INTO :V1-Vnn  technique to generate the SAS macro variables.&lt;BR /&gt;
&lt;BR /&gt;
Here is a useful Google advanced search argument which provides some matches for reference and examples:&lt;BR /&gt;
&lt;BR /&gt;
proc sql generate macro variable list into site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/VARNAME&gt;</description>
      <pubDate>Tue, 15 Sep 2009 16:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71611#M20664</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-15T16:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71612#M20665</link>
      <description>I tried to do the same thing but it wasnt doing it. &lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select column1 into :name1-:name&amp;amp;totobs&lt;BR /&gt;
from work.filenames_list;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;&amp;amp;name&amp;amp;5;&lt;BR /&gt;
(It does not resolove)&lt;BR /&gt;
&lt;BR /&gt;
I think I'm writing it wrong at name&amp;amp;totobs. How should I do it?</description>
      <pubDate>Tue, 15 Sep 2009 17:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71612#M20665</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-15T17:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71613#M20666</link>
      <description>After your PROC SQL executes, issue the command:&lt;BR /&gt;
&lt;BR /&gt;
%PUT _USER_;&lt;BR /&gt;
&lt;BR /&gt;
The output will show you the SAS macro variables generated, if any, by your PROC SQL execution.&lt;BR /&gt;
&lt;BR /&gt;
And if you are trying to iterate through the variable list, please share all of the related macro code you are executing, preferably in a SAS log perspective, with any errors.  This info will help with providing feedback.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 15 Sep 2009 18:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71613#M20666</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-15T18:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71614#M20667</link>
      <description>When I use %put _user_; &lt;BR /&gt;
It does list all the variables in the log. But, It does not resolve when i use %put &amp;amp;&amp;amp;name&amp;amp;i.&lt;BR /&gt;
&lt;BR /&gt;
My later part of the code looks like this and it does not resolve there too.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
853&lt;BR /&gt;
854&lt;BR /&gt;
855  %do i=1 %to &amp;amp;totobs;&lt;BR /&gt;
ERROR: The %DO statement is not valid in open code.&lt;BR /&gt;
856&lt;BR /&gt;
857  %if %sysfunc(fileexist("C:\DandS\Mydoc\RawData\&amp;amp;&amp;amp;name&amp;amp;i..dat")) = 1&lt;BR /&gt;
ERROR: The %IF statement is not valid in open code.&lt;BR /&gt;
858  %then %do;&lt;BR /&gt;
NOTE: PROCEDURE EXPORT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.</description>
      <pubDate>Tue, 15 Sep 2009 18:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71614#M20667</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-15T18:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71615#M20668</link>
      <description>You have SAS macro code %DO/%END that is not contained in a defined macro, which is required.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SASâ Macro Programming for Beginners&lt;BR /&gt;
Susan J. Slaughter, Avocet Solutions, Davis, CA&lt;BR /&gt;
Lora D. Delwiche, Delwiche Consulting, Winters, CA&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/243-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/243-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Using PROC SQL with the SAS Macro Facility&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm&lt;/A&gt;</description>
      <pubDate>Tue, 15 Sep 2009 19:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71615#M20668</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-15T19:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71616#M20669</link>
      <description>Thank you, I got it</description>
      <pubDate>Tue, 15 Sep 2009 20:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71616#M20669</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-15T20:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: create macro variables for list of observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71617#M20670</link>
      <description>This work can be also done with the SYMPUT CALL in a data step:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
	input var1 $ @@;&lt;BR /&gt;
cards;&lt;BR /&gt;
a b c d e f g&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	set have;&lt;BR /&gt;
	call symput ("name"||strip(_n_),var1);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%put _global_;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Yuewei</description>
      <pubDate>Wed, 16 Sep 2009 06:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/create-macro-variables-for-list-of-observations/m-p/71617#M20670</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-16T06:18:52Z</dc:date>
    </item>
  </channel>
</rss>

