<?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 how to create a macro using dataset values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663343#M197994</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a macro that hold all avisit values, that way i don't have to manual check the data if there's new visits in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my starting point, getting all avisitn values in adlb then using avisitn values to create a table shell/dummy dataset "&amp;amp;avisitn".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=adlb out=shell_ (keep=avisitn) nodupkey;
by avisitn;
run;


data shell;
   set shell_;
	  do ord1= &amp;amp;avisitn;  /*avisitn values go here*/
	  output;
	  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 Jun 2020 23:08:01 GMT</pubDate>
    <dc:creator>HitmonTran</dc:creator>
    <dc:date>2020-06-18T23:08:01Z</dc:date>
    <item>
      <title>how to create a macro using dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663343#M197994</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a macro that hold all avisit values, that way i don't have to manual check the data if there's new visits in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my starting point, getting all avisitn values in adlb then using avisitn values to create a table shell/dummy dataset "&amp;amp;avisitn".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=adlb out=shell_ (keep=avisitn) nodupkey;
by avisitn;
run;


data shell;
   set shell_;
	  do ord1= &amp;amp;avisitn;  /*avisitn values go here*/
	  output;
	  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 23:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663343#M197994</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-06-18T23:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a macro using dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663346#M197996</link>
      <description>&lt;P&gt;Your question is not very clear. If you want a list of all unique values as a single macro variable you can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select distinct avisitn into: avisitn separated by ',' from adlb;
quit;
%put &amp;amp;avisitn;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if you are doing the way you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length avisitn_string $32767.;
set shell_ end=last;
retain avisitn_string '';
 avisitn_string = strip( avisitn_string)||','||strip(put(avisitn,$5.));
if last then call symputx('avisitn',avisitn_string);
run;
%put &amp;amp;avisitn.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 23:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663346#M197996</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-18T23:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a macro using dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663359#M197999</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;create a table shell/dummy dataset "&amp;amp;avisitn".&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Do you want to create one data set by visit?&lt;/P&gt;
&lt;P&gt;I can't think of a reason where this could ever be justified.&lt;/P&gt;
&lt;P&gt;What's the purpose?&lt;/P&gt;
&lt;P&gt;Anyway, if that variable is numeric, this does what you seem to be asking:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select distinct AVISITN into: avisitn separated by ',' from ADLB order by AVISITN;
quit;
%put &amp;amp;=avisitn;

data X;
  do ORD1= &amp;amp;avisitn.;  /*avisitn values go here*/
	  /* Some code */
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 02:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-macro-using-dataset-values/m-p/663359#M197999</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-19T02:12:13Z</dc:date>
    </item>
  </channel>
</rss>

