<?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: Macro - multiple dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715331#M220935</link>
    <description>&lt;P&gt;Here is one of the ways to "split" data that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, no macro needed at this stage though writing 20 outputs like this does take a small amount of time:&lt;/P&gt;
&lt;PRE&gt;data patient;
   input Name $ income visit  Spend  ;
datalines;
Alex     100  10.45        10.20      
Bruce   200  2.51          50.21    
Candy  150   5.21        15.21    
;

data Alex
     Bruce
     Candy
;
   set patient;
   select (name);
      when ("Alex") output Alex;
      when ("Bruce") output Bruce;
      when ("Candy") output Candy;
      otherwise ;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;But really, how do you intend to use those 20 data sets?&lt;/P&gt;
&lt;P&gt;If you want to do analysis on a subset of the data you can use WHERE to restrict it to specific names:&lt;/P&gt;
&lt;PRE&gt;proc means data=patient;
   where name in ('Alex' 'Candy');
   var income spend;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jan 2021 15:42:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-29T15:42:13Z</dc:date>
    <item>
      <title>Macro - multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715192#M220897</link>
      <description>&lt;P&gt;hi everyone,&lt;/P&gt;&lt;P&gt;I need to create a dataset for EACH of the 20 patients using MACRO.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset shown below have 20 patient names and 3 variables - their&amp;nbsp; income, average number of visits to doctors in last 3 months and average healthcare spending.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; income visit&amp;nbsp; Spend&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&amp;nbsp; 10.45&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10.20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bruce&amp;nbsp;&amp;nbsp; 200&amp;nbsp; 2.51&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50.21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Candy&amp;nbsp; 150&amp;nbsp;&amp;nbsp; 5.21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15.21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;i tried the following but it is not creating any dataset at all&lt;/P&gt;&lt;P&gt;data serial;&lt;BR /&gt;set patient;&lt;/P&gt;&lt;P&gt;call symput('Name', Name);&lt;BR /&gt;call symput('Income', Income);&lt;BR /&gt;call symput('Visit', Visit);&lt;BR /&gt;call symput('Spend', Spend);&lt;/P&gt;&lt;P&gt;call symputx('numnames',_n_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%patient(&amp;amp;Name, &amp;amp;Income, &amp;amp;Visit, &amp;amp;Spend,&amp;amp;Count);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please advice&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 07:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715192#M220897</guid>
      <dc:creator>Joyful3</dc:creator>
      <dc:date>2021-01-29T07:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715193#M220898</link>
      <description>&lt;P&gt;Do each patient have several observations in your data?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 07:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715193#M220898</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-29T07:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715226#M220907</link>
      <description>&lt;P&gt;Want do you want to do with the data you have ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the data one row per patient name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably don't need to separate the data by name into different data sets because the data you already have appears to be one row of aggregate results (income, mean visits (maybe should be count?) and mean spending (per visit?)), for each patient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might be well served with a BY statement somewhere in your downstream processing if you join your aggregates with other detail data.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 11:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715226#M220907</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2021-01-29T11:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715236#M220913</link>
      <description>&lt;P&gt;&lt;STRONG&gt;NO&lt;/STRONG&gt; SAS processing I can think of requires you to split such a minuscule dataset.&lt;/P&gt;
&lt;P&gt;So my advice is very simple: don't.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 12:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715236#M220913</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-29T12:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715331#M220935</link>
      <description>&lt;P&gt;Here is one of the ways to "split" data that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, no macro needed at this stage though writing 20 outputs like this does take a small amount of time:&lt;/P&gt;
&lt;PRE&gt;data patient;
   input Name $ income visit  Spend  ;
datalines;
Alex     100  10.45        10.20      
Bruce   200  2.51          50.21    
Candy  150   5.21        15.21    
;

data Alex
     Bruce
     Candy
;
   set patient;
   select (name);
      when ("Alex") output Alex;
      when ("Bruce") output Bruce;
      when ("Candy") output Candy;
      otherwise ;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;But really, how do you intend to use those 20 data sets?&lt;/P&gt;
&lt;P&gt;If you want to do analysis on a subset of the data you can use WHERE to restrict it to specific names:&lt;/P&gt;
&lt;PRE&gt;proc means data=patient;
   where name in ('Alex' 'Candy');
   var income spend;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 15:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-multiple-dataset/m-p/715331#M220935</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-29T15:42:13Z</dc:date>
    </item>
  </channel>
</rss>

