<?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: Assign varable to a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494857#M130491</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a macrovariable per observation ? If so, you can suffix macrovariable names with row index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
    set cities;
    call symput(cats("city_",_N_), city);
run;

%put &amp;amp;city_10. &amp;amp;city_42.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want a macrovariable listing all values of the same variable :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    SELECT city
    INTO :lst_cities SEPARATED BY ','
    FROM cities;
quit;&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;lst_cities.;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Sep 2018 13:48:10 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-09-12T13:48:10Z</dc:date>
    <item>
      <title>Assign varable to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494849#M130485</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a dataset with 100 obs and one variable of city.&lt;/P&gt;&lt;P&gt;how can i assign all the values to a macro varible using callsymput?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 13:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494849#M130485</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2018-09-12T13:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assign varable to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494853#M130488</link>
      <description>&lt;P&gt;So this is quite unclear what you want to do, and it would be nice if you showed up (for a simple example of say 3 observations) what macro variables you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me ask ... do you want one macro variable that contains ALL 100 of the city names? Or do you want 100 macro variables, each containing a single city name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its also possible that limiting the solutions to CALL SYMPUT is not a good decision. It may also be true that you don't even need macros, depending on what you want to do next.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 13:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494853#M130488</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-12T13:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Assign varable to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494856#M130490</link>
      <description>&lt;P&gt;You don't need to, if you have data in a dataset, then there are simpler, more efficient methods of coding using that than using macro.&amp;nbsp; For example, one often used ones is for where clauses, so avoid all that nasty macro, convert spaces to commas, ensure correct quoting etc. and simply do:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select *
  from   adataset
  where city in (select city from 100obsdataset);
quit;&lt;/PRE&gt;
&lt;P&gt;With that its simple coding, and the dataset can shrink/expand as needed.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 13:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494856#M130490</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-12T13:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Assign varable to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494857#M130491</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a macrovariable per observation ? If so, you can suffix macrovariable names with row index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
    set cities;
    call symput(cats("city_",_N_), city);
run;

%put &amp;amp;city_10. &amp;amp;city_42.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want a macrovariable listing all values of the same variable :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    SELECT city
    INTO :lst_cities SEPARATED BY ','
    FROM cities;
quit;&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;lst_cities.;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 13:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-varable-to-a-macro/m-p/494857#M130491</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-12T13:48:10Z</dc:date>
    </item>
  </channel>
</rss>

