<?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 outputing different data sets in a data sets within a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/373252#M276191</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I want to output different data sets within a macro depending on the number categories of the categorical variable in use. For example, let’s say if I have the variable income with 4 categories[-, 50 000),(50 000, 80 000],(80 000, 120 000], (120 000, +0).&lt;/P&gt;&lt;P&gt;The code I have for this is the following:&lt;/P&gt;&lt;P&gt;data data_50 data_50to80 data._80to120 data120;&lt;/P&gt;&lt;P&gt;set dataX;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;var = '[-, 50 000)' then output data_50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if &amp;amp;var = '(50 000, 80 000]' then output data_50to80;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if &amp;amp;var = '(80 000, 120 000]' then output data_80to120;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if &amp;amp;var = '(120 000, +]' then output data_120;&lt;/P&gt;&lt;P&gt;drop &amp;amp;var;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;where &amp;amp;var is a macro variable I created for the macro (&amp;amp;var=income). I want to be able to perform the previous data step with other categorical variables with different number categories. For example: score (low, medium, high). After I have those data sets, I want to be able to transpose them each one of them, and then ‘set’ them in a subsequent data set.&lt;/P&gt;&lt;P&gt;Could you please suggest me how to do so?&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2017 13:09:35 GMT</pubDate>
    <dc:creator>alexgonzalez</dc:creator>
    <dc:date>2017-07-05T13:09:35Z</dc:date>
    <item>
      <title>outputing different data sets in a data sets within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/373252#M276191</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I want to output different data sets within a macro depending on the number categories of the categorical variable in use. For example, let’s say if I have the variable income with 4 categories[-, 50 000),(50 000, 80 000],(80 000, 120 000], (120 000, +0).&lt;/P&gt;&lt;P&gt;The code I have for this is the following:&lt;/P&gt;&lt;P&gt;data data_50 data_50to80 data._80to120 data120;&lt;/P&gt;&lt;P&gt;set dataX;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;var = '[-, 50 000)' then output data_50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if &amp;amp;var = '(50 000, 80 000]' then output data_50to80;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if &amp;amp;var = '(80 000, 120 000]' then output data_80to120;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if &amp;amp;var = '(120 000, +]' then output data_120;&lt;/P&gt;&lt;P&gt;drop &amp;amp;var;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;where &amp;amp;var is a macro variable I created for the macro (&amp;amp;var=income). I want to be able to perform the previous data step with other categorical variables with different number categories. For example: score (low, medium, high). After I have those data sets, I want to be able to transpose them each one of them, and then ‘set’ them in a subsequent data set.&lt;/P&gt;&lt;P&gt;Could you please suggest me how to do so?&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/373252#M276191</guid>
      <dc:creator>alexgonzalez</dc:creator>
      <dc:date>2017-07-05T13:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: outputing different data sets in a data sets within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/373261#M276192</link>
      <description>&lt;P&gt;I would suggest that its not a good idea to duplicate your data over and over again just to add categories, create category variables in the one dataset. In the example you have given, you can create a format, then apply that format into a new variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value grp1
    0-50000="data_50"
    50000-80000="data_80"
...
;
run;

data want;
  length cat1 $20;
  cat1=put(yourval,grp1.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are lots of little tricks like this using formats. &amp;nbsp;So create one dataset, with different categories cat1 cat2 etc. for each categorisation. &amp;nbsp;Then you can where or by group based on them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/373261#M276192</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-05T13:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: outputing different data sets in a data sets within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/374004#M276193</link>
      <description>Thanks a lot.&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Jul 2017 15:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/outputing-different-data-sets-in-a-data-sets-within-a-macro/m-p/374004#M276193</guid>
      <dc:creator>alexgonzalez</dc:creator>
      <dc:date>2017-07-07T15:46:39Z</dc:date>
    </item>
  </channel>
</rss>

