<?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 from Data Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955858#M373281</link>
    <description>&lt;P&gt;Data, like these two text values, is much more easily handled in a SAS data set. It is much less easily handled in a macro. While there are reasons why a macro may be the best choice, those reasons are rare. We could give you better advice if we knew what you are planning to do with these character strings. Please tell us what you are going to do next with these character strings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A minor comment about terminology: you are not creating a macro, you care creating a macro variable. Macro variables are not the same as macros.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2025 01:07:55 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-01-13T01:07:55Z</dc:date>
    <item>
      <title>Create Macro from Data Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955850#M373278</link>
      <description>&lt;P&gt;I have the following example data set:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  test = "A123"; output;
  test = "B123"; output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like to to assign the values A123 and B123 into a macro so that the result would be the same as :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let readin=("A123" "B123")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I would use &amp;amp;readin. in data step's where statement.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2025 20:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955850#M373278</guid>
      <dc:creator>trevand</dc:creator>
      <dc:date>2025-01-12T20:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create Macro from Data Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955851#M373279</link>
      <description>&lt;P&gt;One common way to read a list of values from a dataset variable into a macro variable is to use PROC SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
  select quote(test) into :readin separated by " " 
  from test
  ;
quit ;

%put &amp;amp;readin ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will return:&lt;/P&gt;
&lt;PRE&gt;"A123" "B123"
&lt;/PRE&gt;
&lt;P&gt;If you want to include the parentheses in the value, I think the easiest way is to add them with a %LET statement after the PROC SQL step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
  select quote(test) into :readin separated by " " 
  from test
  ;
quit ;
%let readin=(&amp;amp;readin) ;

%put &amp;amp;readin ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Jan 2025 20:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955851#M373279</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-01-12T20:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create Macro from Data Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955858#M373281</link>
      <description>&lt;P&gt;Data, like these two text values, is much more easily handled in a SAS data set. It is much less easily handled in a macro. While there are reasons why a macro may be the best choice, those reasons are rare. We could give you better advice if we knew what you are planning to do with these character strings. Please tell us what you are going to do next with these character strings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A minor comment about terminology: you are not creating a macro, you care creating a macro variable. Macro variables are not the same as macros.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 01:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955858#M373281</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-13T01:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create Macro from Data Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955867#M373288</link>
      <description>&lt;P&gt;I am using it to load in only a subset of a huge data set. So in the data step I restrict using where=(variable in (@readin.))&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 02:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Macro-from-Data-Values/m-p/955867#M373288</guid>
      <dc:creator>trevand</dc:creator>
      <dc:date>2025-01-13T02:53:08Z</dc:date>
    </item>
  </channel>
</rss>

