<?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 for Categorical variables using proc freq in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124970#M294170</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wonder how you would have to change your macro to allow LIST_OF_VARS to be a "SAS Variable List"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%freqs(list_of_vars=A--E);&lt;/P&gt;&lt;P&gt;%freqs(list_of_vars=_CHAR_);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Mar 2013 13:46:17 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2013-03-01T13:46:17Z</dc:date>
    <item>
      <title>Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124966#M294166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need all your help . I need a macro which can run all possible combinations for the N number of variables inside a proc freq.&lt;/P&gt;&lt;P&gt;For eg.&lt;/P&gt;&lt;P&gt;I have 5 variables. Say A B C D and E&amp;nbsp; all are binary . I need a 2 way classifcation of variables using proc freq. like it should generate&lt;/P&gt;&lt;P&gt;frequencies for AB AC AD AE BC BD BE CD and CE.&lt;/P&gt;&lt;P&gt;Now how i am doing is passing the values for each combination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro freqproc freq data=chk;&lt;/P&gt;&lt;P&gt;table &amp;amp;var1*&amp;amp;var2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend freq;&lt;/P&gt;&lt;P&gt;%freq(var1=a , var2=b);&lt;/P&gt;&lt;P&gt;%freq(var1=a, var2=c);&lt;/P&gt;&lt;P&gt;.................................&lt;/P&gt;&lt;P&gt;................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i need an help on is that instead of pasing the values like this. I need an macro which can in one shot give me frequency for all possible combination. Please help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 12:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124966#M294166</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-01T12:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124967#M294167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a problem doing Table (A B C D E)*(A B C D E)?&amp;nbsp; There will be 5 extra tables (AA BB CC DD EE) but those could be deleted out using ODS document features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a thought,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 12:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124967#M294167</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-03-01T12:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124968#M294168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think &lt;A __default_attr="9627" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; has the best idea.&amp;nbsp; No macro involved is always at the top of my list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another possibility would be to use the WAYS statement in PROC SUMMARY.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;CLASS A B C D E;&lt;/P&gt;&lt;P&gt;WAYS 2;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 13:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124968#M294168</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-03-01T13:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124969#M294169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the fastest way is to go with reply of EJ. Anyway a macro could like this&lt;/P&gt;&lt;P&gt;/*just for quick test*/&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;A=1;B=2;C=3;D=4;E=5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*macro definition*/&lt;/P&gt;&lt;P&gt;%macro freqs(list_of_vars=,dataset=);&lt;/P&gt;&lt;P&gt;%local num_of_all test_number i;&lt;/P&gt;&lt;P&gt;%let num_of_all=%sysfunc(countw(&amp;amp;list_of_vars));&lt;/P&gt;&lt;P&gt;%let test_number=%sysfunc(comb(&amp;amp;num_of_all.,2));&lt;/P&gt;&lt;P&gt;proc plan;&lt;/P&gt;&lt;P&gt;&amp;nbsp; factors test_number=&amp;amp;test_number ordered&lt;/P&gt;&lt;P&gt;&amp;nbsp; class= 2 of &amp;amp;num_of_all. comb ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output plan=combinations;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set combinations;&lt;/P&gt;&lt;P&gt;call symputx('first'||strip(put(_N_,best12.)),class1);&lt;/P&gt;&lt;P&gt;call symputx('second'||strip(put(_N_,best12.)),class2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%do i = 1 %to &amp;amp;test_number.;&lt;/P&gt;&lt;P&gt;proc freq data=&amp;amp;dataset.;&lt;/P&gt;&lt;P&gt;table %scan(&amp;amp;list_of_vars.,&amp;amp;&amp;amp;first&amp;amp;i)*%scan(&amp;amp;list_of_vars.,&amp;amp;&amp;amp;second&amp;amp;i)/out=freq&amp;amp;i.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend freqs;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*macrocall*/&lt;/P&gt;&lt;P&gt;%freqs(list_of_vars=A B C D E,dataset=test);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Jakub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 13:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124969#M294169</guid>
      <dc:creator>chrej5am</dc:creator>
      <dc:date>2013-03-01T13:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124970#M294170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wonder how you would have to change your macro to allow LIST_OF_VARS to be a "SAS Variable List"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%freqs(list_of_vars=A--E);&lt;/P&gt;&lt;P&gt;%freqs(list_of_vars=_CHAR_);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 13:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124970#M294170</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-03-01T13:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124971#M294171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro twoway(varlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%local i j;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do i=1 %to %sysfunc(countw(&amp;amp;varlist,%str( )))-1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do j=&amp;amp;i+1 %to %sysfunc(countw(&amp;amp;varlist,%str( )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%scan(&amp;amp;varlist,&amp;amp;i)*%scan(&amp;amp;varlist,&amp;amp;j)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;tables %twoway(A B C D E) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 13:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124971#M294171</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-01T13:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124972#M294172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply and help. Can we also extend this to more than A B C D E&amp;nbsp; what i mean is&amp;nbsp; for 'N' number of variables?&lt;/P&gt;&lt;P&gt;Please let me know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks and regards,&lt;/P&gt;&lt;P&gt;S.S.Pradeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 06:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124972#M294172</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-04T06:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124973#M294173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for the reply. It worked perfectly. Just would like to know since here we are having only 5 variables. say from A to E . so its easy to assign numbers to them from 1-5. Suppose we have 1000 variables will that be feasible to assign 1000 numbers to all the variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know your thoughts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 06:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124973#M294173</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-04T06:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124974#M294174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you .It worked perfectly .I also need one help suppose we have 100 variables then how can we list then inside the macros . its not possible to give all the 100 variables inside the proc freq. In this example we have just 5 variables so we could list them . Can we have generalized code to include all the 100 variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;Can we extend this to a Three way or Four way classifcation?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Please let me know your thoughts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;S.S.Pradeep&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: pradeep sridharan&#xD;
&#xD;
Can we&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 06:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124974#M294174</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-04T06:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124975#M294175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you. As of now its creating all the combinations. i need one more favour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the 5 variables are binary. for eg. A has value 0 and 1, B has a value 0 and 1 and C....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what i need an help on is . 0 of A with 1 of B,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 of A with 0 of B,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 of A with 1 of B,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 of A with 0 of B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the macro i am looking out for should do for all the A to E variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know the thoughts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;S.S.Pradeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 07:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124975#M294175</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-04T07:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124976#M294176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can extend it as much as you want. To generate two way combinations I use two %DO loops.&amp;nbsp; To generate three way you would want to code three %DO loops. etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many ways to ask SAS to tell you what variables are in a dataset. &lt;/P&gt;&lt;P&gt;If you really want the flexibility in specifying variables and combinations of variables then use PROC SUMMARY instead of PROC FREQ.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 10:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124976#M294176</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-04T10:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124977#M294177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think it makes any difference whether the variable has two levels or twenty when requesting a frequency table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 10:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124977#M294177</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-04T10:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124978#M294178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the tips. Please find below the code which i am trying.. but unable to get the desire results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have four variables - 1) b5_own has two values ( 0 ,1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2) AA1 has two values (0 ,1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3) brand ( has 20 brands)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4) market ( has 10 markets)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I have modified your code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro twoway(varlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%local i j k l;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do i=1 %to %sysfunc(countw(&amp;amp;varlist,%str( )))-1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do j=&amp;amp;i+1 %to %sysfunc(countw(&amp;amp;varlist,%str( )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do k=1 %to %sysfunc(countw(&amp;amp;varlist,%str( )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do l=1 %to %sysfunc(countw(&amp;amp;varlist,%str( )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%scan(&amp;amp;varlist,&amp;amp;i)*%scan(&amp;amp;varlist,&amp;amp;j)*&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%scan(&amp;amp;varlist,&amp;amp;k)*%scan(&amp;amp;varlist,&amp;amp;l)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc freq data=chks;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;tables %twoway(b5_own aa1 brand market) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;weight weight;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Can you please guide where the mistake is because i couldnt match the numbers..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Thanks and Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S.S.Pradeep&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 06:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124978#M294178</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-05T06:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124979#M294179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have four variables and you want them all crossed in a TABLES statement then just separate them with * instead of spaces.&lt;/P&gt;&lt;P&gt;If you want to modify the little pair generating macro to generate four-way crossing then you will need to adjust the upper and lower bounds of the do loops.&lt;/P&gt;&lt;P&gt;%let n=%sysfunc(countw(&amp;amp;varlist));&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;N-3;&lt;/P&gt;&lt;P&gt; %do j=&amp;amp;i+1 %to &amp;amp;N-2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do k=&amp;amp;j+1 %to &amp;amp;N-1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do l=&amp;amp;k+1 %to &amp;amp;N ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why not just use PROC SUMMARY?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Compare the output dataset you get with this PROC FREQ call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq;&lt;/P&gt;&lt;P&gt; tables b5_own*aa1*brand*market /noprint out=freq ;&lt;/P&gt;&lt;P&gt; weight weight ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the output dataset you get with this PROC SUMMARY call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc summary data = sample ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var weight ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class b5_own aa1 brand market ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ways 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output out=summary sum=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 12:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124979#M294179</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-05T12:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124980#M294180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the guidance. As you suggested Proc summary is the best choice. I tried running both proc freq and proc summary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Proc freq - i got the percent frequency count and percentage of total frequency in the output dataset - so if i remove the noprint option and run i am getting the exact number which i am looking out for.&lt;/P&gt;&lt;P&gt;2. proc summary - here i got the type , freq and weight in the output dataset. how can i go about in converting or transpoing the dataset to the exact percentage i am getting in proc freq.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please guide,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;S.S.Pradeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 06:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124980#M294180</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-06T06:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124981#M294181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need one more guidance on the proc frequency.&amp;nbsp; I have report to be generated with 250 attributes or variables. in the below code i want the attributes to keep changing till 250 automatically and get the combination. is there any way or do i need to hardcode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq;&lt;/P&gt;&lt;P&gt;tables brand*market*aa1*(attrib1)*b5_own /noprint out=freq ;&lt;/P&gt;&lt;P&gt;weight weight ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i am currently doing is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro attrib;&lt;/P&gt;&lt;P&gt;proc freq;&lt;/P&gt;&lt;P&gt;tables brand*market*aa1*(&amp;amp;attributes)*b5_own /noprint out=freq ;&lt;/P&gt;&lt;P&gt;weight weight ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend attrib;&lt;/P&gt;&lt;P&gt;%attrib (attributes= attrib1 attrib2 attrib3.....till attrib250).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please guide is there any smarter way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;S.S.Pradeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 06:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124981#M294181</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-06T06:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124982#M294182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your variables are named with numeric suffixes as in your example then you can use variable list syntax.&lt;/P&gt;&lt;P&gt;attrib1 - attrib250 &lt;/P&gt;&lt;P&gt;If not, but you know the physical order of the variables in the dataset then you can use -- between the names&lt;/P&gt;&lt;P&gt;age -- race &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 15:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124982#M294182</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-06T15:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Categorical variables using proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124983#M294183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the guidance. As you suggested Proc summary is the best choice. I tried running both proc freq and proc summary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Proc freq - i got the percent frequency count and percentage of total frequency in the output dataset - so if i remove the noprint option and run i am getting the exact number which i am looking out for.&lt;/P&gt;&lt;P&gt;2. proc summary - here i got the type , freq and weight in the output dataset. how can i go about in converting or transpoing the dataset to the exact percentage i am getting in proc freq.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please guide,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;S.S.Pradeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Mar 2013 08:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Categorical-variables-using-proc-freq/m-p/124983#M294183</guid>
      <dc:creator>srisaipradeep</dc:creator>
      <dc:date>2013-03-07T08:10:56Z</dc:date>
    </item>
  </channel>
</rss>

