<?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: sas macro? or loop? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273312#M54456</link>
    <description>&lt;P&gt;Where are your DATA= statements/portion of the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this operating on the same dataset? What's the end goal/rationale for doing this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder if there's a better way to get what you need, it doesn't make a lot of sense to me to re-run the same procedure by different order except possibly for printing and manual review.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2016 16:00:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-05-26T16:00:37Z</dc:date>
    <item>
      <title>sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273283#M54443</link>
      <description>&lt;P&gt;I am new to SAS, i am trying to do something that would allow me to run this code , but with a different variable everytime. If put in different variables in the parenthesis then it sorts it and seperates out each of the variables, i want to have it sorted by variable and then by q2&amp;nbsp; and by q3.&amp;nbsp; How can i do this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; q2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;freq&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; (bmicat) *school;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; q2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; q2 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;q2f.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sort&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; q3;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;freq&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; (bmicat)*school;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; q3;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; q3 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;q3f.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;freq&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; (bmicat)*school;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 15:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273283#M54443</guid>
      <dc:creator>ml31</dc:creator>
      <dc:date>2016-05-26T15:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273294#M54446</link>
      <description>Well, you can assign a macro variable like this:&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let variableName = whatever;&lt;/CODE&gt;&lt;/PRE&gt;Later, you use it like so:&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;variableName&lt;/CODE&gt;&lt;/PRE&gt;or, if you want it in a character string:&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;variableName."&lt;/CODE&gt;&lt;/PRE&gt;As your title suggests, you can use a loop:&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 2 %to 3;
    proc sort;
        by q&amp;amp;i;
    proc freq;
        table (bmicat) *school;
        by q&amp;amp;i;
        format q&amp;amp;i q&amp;amp;i.f.;
%end;
proc freq;
    table (bmicat)*school;
run;&lt;/CODE&gt;&lt;/PRE&gt;During the first iteration, i will be 2; during the second, it will be 3. SAS will replace &amp;amp;i with those values, respectively. The reason you might include a . after &amp;amp;i is because otherwise when you set the format, SAS thinks you want a macro variable called &amp;amp;if, but you have not defined it.</description>
      <pubDate>Thu, 26 May 2016 15:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273294#M54446</guid>
      <dc:creator>paulkaefer</dc:creator>
      <dc:date>2016-05-26T15:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273312#M54456</link>
      <description>&lt;P&gt;Where are your DATA= statements/portion of the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this operating on the same dataset? What's the end goal/rationale for doing this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder if there's a better way to get what you need, it doesn't make a lot of sense to me to re-run the same procedure by different order except possibly for printing and manual review.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 16:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273312#M54456</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-26T16:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273315#M54458</link>
      <description>&lt;P&gt;Here's an approach you might want to look at:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq;&lt;/P&gt;
&lt;P&gt;tables q2 * (bmicat) * school;&lt;/P&gt;
&lt;P&gt;tables q3 * (bmicat) * school;&lt;/P&gt;
&lt;P&gt;tables (bmicat) * school;&lt;/P&gt;
&lt;P&gt;format q2 q2f. q3 q3f.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The percentages may come out a little differently, but if this is sufficient then you are home free with no sorting, no loops and no macros.&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 16:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273315#M54458</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-26T16:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273320#M54460</link>
      <description>&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;tables (q2 q3)&amp;nbsp;* (bmicat * school);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also depending on exactly what you are looking for a different procedure might work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class q2 q3 bmicat school;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format q2 q2f. q3 q3f.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; table q2, /*&amp;lt; one output table per formatted level*/&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; bmicat,&amp;nbsp; /* one row per value/formatted level*/&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; school * (n colpctn rowpctn); /* column headed by school with statistics under*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; table q3,&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; bmicat,&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; school * (n colpctn rowpctn);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Though tabulate treats missing somewhat differently than freq but useful and CLASS variables do not require sorting.&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 17:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273320#M54460</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-26T17:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273418#M54482</link>
      <description>&lt;P&gt;This is the same data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data portion has a lot of if/then where i create dichotomous variables out of multi-answer survey questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What the sort does, is it sorts it by gender and by grade, so i do need each variable sorted this way.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What i would like to do though is instead of deleting the variable and typing the next one, is to just enter all the variables at once and have the output be by variable where the variable is sorted by gender and grade.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so if i do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq;&lt;/P&gt;&lt;P&gt;tables (variable1 variable2 variable3 variable4 ....)*school&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i would like the output to be each variable, sorted by corresponding gender variable and grade variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does this sort of make sense? i need this to enter the data in a report, it would just be easier than going back and forth between variables to see the gender and grade.&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 21:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273418#M54482</guid>
      <dc:creator>ml31</dc:creator>
      <dc:date>2016-05-26T21:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273423#M54484</link>
      <description>&lt;P&gt;This does work but it gives me all the different variables that i would put instead of BMICAT by q2 (gender) and then all the different variables by q3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to have the variable by q2 and by q3 but i want to keep that variable together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i want th eoutput to read&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;variable1 by gender&lt;/P&gt;&lt;P&gt;variable1 by grade&lt;/P&gt;&lt;P&gt;variable 1 overall freq&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;variable 2 by gender&lt;/P&gt;&lt;P&gt;variable 2 by grade&lt;/P&gt;&lt;P&gt;variable&amp;nbsp;2 overall freq&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but right now when i do this it gives me output like this&lt;/P&gt;&lt;P&gt;variable 1 by gender&lt;/P&gt;&lt;P&gt;variable 2 by gender&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;variable 1 by grade&lt;/P&gt;&lt;P&gt;variable 2 by grade&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;variable 1 overall&lt;/P&gt;&lt;P&gt;variable 2 overall&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>Thu, 26 May 2016 21:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273423#M54484</guid>
      <dc:creator>ml31</dc:creator>
      <dc:date>2016-05-26T21:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro? or loop?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273436#M54485</link>
      <description>&lt;P&gt;That depends on how you write your table statement. It's hard to work without sample data, but does this look close:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
set sashelp.class;
array q(5) q1-q5;

do i=1 to 5;
q(i)=rand('bernoulli', 0.4);
end;

output;
run;

proc freq data=sample;
table (q1 q2 q3 q4 q5)*sex*age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 22:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-or-loop/m-p/273436#M54485</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-26T22:53:00Z</dc:date>
    </item>
  </channel>
</rss>

