<?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: What function to use for multiple data set? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286763#M58895</link>
    <description>&lt;P&gt;To run the statistics for each&amp;nbsp; year, you can do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro stats;
%do year = 2000 %to 2015;
proc means data=mylib.data_&amp;amp;year;
.......
run;
%end;
%mend;
%stats;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, if you have the year in the dataset in a variable, you could do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro stats;
data work.statview/view=work.statview;
set
%do year = 2000 %to 2015;
  mylib.data&amp;amp;year
%end;
;
run;

proc means data=work.statview;
by yearvar;
.....
run;
%mend;
%stats;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2016 05:24:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-07-25T05:24:51Z</dc:date>
    <item>
      <title>What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286754#M58889</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm analyzing data from year 2000 - 2015 with each year having its own data file. Instead of repeating all the procedures yearly, is there a shortcut function where I can analyze all the years with one code? I can try to merge all the files but each file contains around 80 million observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the variables are the same for each year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 03:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286754#M58889</guid>
      <dc:creator>jwill731</dc:creator>
      <dc:date>2016-07-25T03:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286756#M58890</link>
      <description>&lt;P&gt;There isn't a function but you can create a macro. Macro in the simplest form generate code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro below, called sample, runs proc means on the provided dataset. Note how the parameter is referenced within the macro (&amp;amp;datain).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Options MPRINT SYMBOLGEN;

%macro sample(datain);

Proc means data = &amp;amp;datain;
Run;

%mend;

%sample(sashelp.class);
%sample(sashelp.cars);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See a tutorial here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 04:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286756#M58890</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-25T04:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286757#M58891</link>
      <description>Is your analysis "yearly", or are you performing the one analysis across all 15 years? Based on your request, I'm assuming the latter - if you want to avoid combining the tables first, you could instead create a view and then run the analysis on the view, although I'm not sure what your performance will be like.</description>
      <pubDate>Mon, 25 Jul 2016 04:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286757#M58891</guid>
      <dc:creator>AndrewHowell</dc:creator>
      <dc:date>2016-07-25T04:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286759#M58893</link>
      <description>&lt;P&gt;I am analyzing # of visits yearly rather than across 15 years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# of visits in year 2000 = 1.3 million&lt;/P&gt;&lt;P&gt;# of visits in year 2001 = 1.4million&lt;/P&gt;&lt;P&gt;# of visits in year 2002 = 1.5 million&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will be analyzing more than just # of visits but everything will be looked at yearly.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 05:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286759#M58893</guid>
      <dc:creator>jwill731</dc:creator>
      <dc:date>2016-07-25T05:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286760#M58894</link>
      <description>&lt;P&gt;Thank you. I think it's time for me to learn macro&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 05:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286760#M58894</guid>
      <dc:creator>jwill731</dc:creator>
      <dc:date>2016-07-25T05:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286763#M58895</link>
      <description>&lt;P&gt;To run the statistics for each&amp;nbsp; year, you can do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro stats;
%do year = 2000 %to 2015;
proc means data=mylib.data_&amp;amp;year;
.......
run;
%end;
%mend;
%stats;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, if you have the year in the dataset in a variable, you could do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro stats;
data work.statview/view=work.statview;
set
%do year = 2000 %to 2015;
  mylib.data&amp;amp;year
%end;
;
run;

proc means data=work.statview;
by yearvar;
.....
run;
%mend;
%stats;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 05:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286763#M58895</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T05:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: What function to use for multiple data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286795#M58905</link>
      <description>&lt;P&gt;As an alternative, you could do it in one simple datastep:&lt;/P&gt;
&lt;PRE&gt;data tmp;
  do i=2000 to 2015;
    call execute(cats('proc means data=year_',i,'; var age; output out=yr',i,'; run;'));
  end;
  call execute('data want; set yr:; run;');
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 08:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-function-to-use-for-multiple-data-set/m-p/286795#M58905</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-25T08:18:39Z</dc:date>
    </item>
  </channel>
</rss>

