<?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: build a macro for a categorical variable (by taking the counts in to unique macros) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669126#M200689</link>
    <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;BR /&gt;Thank you for your response. Though this can be done by the method you have shown and i could see that its working, but for my further analysis depends on this which for which i would like to macrotize all the individual observations with it's count assigned to individual values.&lt;BR /&gt;Therefore, I would be grateful if you can guide me with your kind response .</description>
    <pubDate>Tue, 14 Jul 2020 09:18:28 GMT</pubDate>
    <dc:creator>sahoositaram555</dc:creator>
    <dc:date>2020-07-14T09:18:28Z</dc:date>
    <item>
      <title>build a macro for a categorical variable (by taking the counts in to unique macros)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669120#M200687</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I've a dataset containing a column named Category like below&lt;/P&gt;
&lt;P&gt;Category&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;I would like to create a macro that gives me output with its count like below&lt;/P&gt;
&lt;P&gt;1- 5&lt;/P&gt;
&lt;P&gt;2-5&lt;/P&gt;
&lt;P&gt;3-4&lt;/P&gt;
&lt;P&gt;4-5&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this i have taken&lt;/P&gt;
&lt;P&gt;%macro cat();&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Received_data = %sysfunc(open(dataset.p1));&lt;BR /&gt;%If &amp;amp;Received_data %Then %Do;&lt;BR /&gt;Proc freq data=dataset.p1;&lt;BR /&gt;Table &amp;amp;col./out=outfile;&lt;BR /&gt;run;&lt;BR /&gt;%End;&lt;/P&gt;
&lt;P&gt;%mend cat();&lt;/P&gt;
&lt;P&gt;Later from this step I'm trying to put it in to call symputx().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If anyone knows a better method to complete this please do help with your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 08:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669120#M200687</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-07-14T08:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: build a macro for a categorical variable (by taking the counts in to unique macros)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669121#M200688</link>
      <description>&lt;P&gt;This is simple summarizing of data, so you don't need a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by category;
if first.category
then count = 1;
else count + 1;
if last.category;
result = catx('-',category,count);
keep result;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jul 2020 08:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669121#M200688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-14T08:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: build a macro for a categorical variable (by taking the counts in to unique macros)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669126#M200689</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;BR /&gt;Thank you for your response. Though this can be done by the method you have shown and i could see that its working, but for my further analysis depends on this which for which i would like to macrotize all the individual observations with it's count assigned to individual values.&lt;BR /&gt;Therefore, I would be grateful if you can guide me with your kind response .</description>
      <pubDate>Tue, 14 Jul 2020 09:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669126#M200689</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-07-14T09:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: build a macro for a categorical variable (by taking the counts in to unique macros)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669127#M200690</link>
      <description>&lt;P&gt;What do you want to do with the strings from the summarization?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 09:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669127#M200690</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-14T09:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: build a macro for a categorical variable (by taking the counts in to unique macros)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669129#M200691</link>
      <description>I will pass them as arguments in to models which i'm building.</description>
      <pubDate>Tue, 14 Jul 2020 09:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669129#M200691</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-07-14T09:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: build a macro for a categorical variable (by taking the counts in to unique macros)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669131#M200692</link>
      <description>&lt;P&gt;So you would have a macro wrapper around your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro run_single(param);
/* your model code here, where &amp;amp;param would be one of the instances from the summarization */
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which you can use from the resulting dataset of my previous code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set want;
call execute('%nrstr(%run_single(' !! result !! '))');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jul 2020 09:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/build-a-macro-for-a-categorical-variable-by-taking-the-counts-in/m-p/669131#M200692</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-14T09:47:48Z</dc:date>
    </item>
  </channel>
</rss>

