<?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 Creating a macro to perform proc means and surveyselect on a dynamic set of tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337092#M272516</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Enterprse MIner 13.1 and am working inside of a SAS Code Node. I have a piece of code that I would like to apply repeatedly to different tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple tables (there could be a different number of these tables each time my code is ran) they are named Work_1, Work_2, Work_3, etc. They all have the same number of columns with the same names. My final goal is a table with the output of every SurveySelect statement (sample_HALT_1&amp;nbsp; UNION ALL&amp;nbsp;sample_HALT_2, etc.) .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The process that I would like to perform on each of these tables is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=Work._1 noprint;
var Diff_MinSS_IndSS;
output out=sample_HALT_1 mean=ha_mean;
run;
data _null_;
set sample_HALT_1;
call symputx('SS_HALT', ha_mean);
run;
%put macro variable SS_HALT: &amp;amp;SS_HALT;


PROC SURVEYSELECT DATA=WORK._1 OUT=sample_HALT_1 METHOD=SRS
  Sampsize= &amp;amp;SS_HALT ;
  RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Natasha&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2017 18:02:30 GMT</pubDate>
    <dc:creator>NatashaLE</dc:creator>
    <dc:date>2017-03-01T18:02:30Z</dc:date>
    <item>
      <title>Creating a macro to perform proc means and surveyselect on a dynamic set of tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337092#M272516</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Enterprse MIner 13.1 and am working inside of a SAS Code Node. I have a piece of code that I would like to apply repeatedly to different tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple tables (there could be a different number of these tables each time my code is ran) they are named Work_1, Work_2, Work_3, etc. They all have the same number of columns with the same names. My final goal is a table with the output of every SurveySelect statement (sample_HALT_1&amp;nbsp; UNION ALL&amp;nbsp;sample_HALT_2, etc.) .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The process that I would like to perform on each of these tables is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=Work._1 noprint;
var Diff_MinSS_IndSS;
output out=sample_HALT_1 mean=ha_mean;
run;
data _null_;
set sample_HALT_1;
call symputx('SS_HALT', ha_mean);
run;
%put macro variable SS_HALT: &amp;amp;SS_HALT;


PROC SURVEYSELECT DATA=WORK._1 OUT=sample_HALT_1 METHOD=SRS
  Sampsize= &amp;amp;SS_HALT ;
  RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Natasha&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 18:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337092#M272516</guid>
      <dc:creator>NatashaLE</dc:creator>
      <dc:date>2017-03-01T18:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro to perform proc means and surveyselect on a dynamic set of tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337094#M272517</link>
      <description>&lt;P&gt;1. No macros required, use BY GROUP processing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&lt;/P&gt;
&lt;P&gt;data work_all;&lt;/P&gt;
&lt;P&gt;set work_: indsname=source;&lt;/P&gt;
&lt;P&gt;dsn = source;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in your next steps add a BY statement using the DSN variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For sample size you can provide the dataset instead of a macro variable so the output from proc means can feed directly into SURVEYSELECT. You may want to round the numbers to a whole number.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 18:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337094#M272517</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-01T18:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro to perform proc means and surveyselect on a dynamic set of tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337845#M272518</link>
      <description>&lt;P&gt;Thank you so much for your response! This suggestion allowed me to greatly simplify the process I was building.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 14:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-to-perform-proc-means-and-surveyselect-on-a/m-p/337845#M272518</guid>
      <dc:creator>NatashaLE</dc:creator>
      <dc:date>2017-03-03T14:53:28Z</dc:date>
    </item>
  </channel>
</rss>

