<?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: Loop to create multiple outputs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-to-create-multiple-outputs/m-p/728317#M226617</link>
    <description>&lt;P&gt;Use a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by year;
run;

proc freq data=have;
by year;
table dz*area;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282708"&gt;@Priyamvada07&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA HAVE;&lt;BR /&gt;input year dz area;&lt;BR /&gt;cards;&lt;BR /&gt;2000 1 08&lt;BR /&gt;2000 1 06&lt;BR /&gt;2000 1 06&lt;BR /&gt;2001 1 08&lt;BR /&gt;2001 1 06&lt;BR /&gt;2001 1 06&lt;BR /&gt;2002 1 08&lt;BR /&gt;2002 1 06&lt;BR /&gt;2002 1 06&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want separate outputs for proc freq dz*area for each year. I can subset data for each year and get the desired table for each year.&lt;/P&gt;
&lt;P&gt;data want_2000;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if year =2000 then output want_2000;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=want_2000;&lt;/P&gt;
&lt;P&gt;table dz*area;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;However, I have too many years to subset the data for each. I want to create a loop to subset each each year's data and then may be a loop to do the proc freq for each subset. Is there a way to use 'array' to be able do what I want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Mar 2021 21:56:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-03-22T21:56:37Z</dc:date>
    <item>
      <title>Loop to create multiple outputs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-to-create-multiple-outputs/m-p/728315#M226616</link>
      <description>&lt;P&gt;I have the following data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA HAVE;&lt;BR /&gt;input year dz area;&lt;BR /&gt;cards;&lt;BR /&gt;2000 1 08&lt;BR /&gt;2000 1 06&lt;BR /&gt;2000 1 06&lt;BR /&gt;2001 1 08&lt;BR /&gt;2001 1 06&lt;BR /&gt;2001 1 06&lt;BR /&gt;2002 1 08&lt;BR /&gt;2002 1 06&lt;BR /&gt;2002 1 06&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want separate outputs for proc freq dz*area for each year. I can subset data for each year and get the desired table for each year.&lt;/P&gt;&lt;P&gt;data want_2000;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if year =2000 then output want_2000;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=want_2000;&lt;/P&gt;&lt;P&gt;table dz*area;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;However, I have too many years to subset the data for each. I want to create a loop to subset each each year's data and then may be a loop to do the proc freq for each subset. Is there a way to use 'array' to be able do what I want?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 21:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-to-create-multiple-outputs/m-p/728315#M226616</guid>
      <dc:creator>Priyamvada07</dc:creator>
      <dc:date>2021-03-22T21:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loop to create multiple outputs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-to-create-multiple-outputs/m-p/728317#M226617</link>
      <description>&lt;P&gt;Use a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by year;
run;

proc freq data=have;
by year;
table dz*area;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282708"&gt;@Priyamvada07&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA HAVE;&lt;BR /&gt;input year dz area;&lt;BR /&gt;cards;&lt;BR /&gt;2000 1 08&lt;BR /&gt;2000 1 06&lt;BR /&gt;2000 1 06&lt;BR /&gt;2001 1 08&lt;BR /&gt;2001 1 06&lt;BR /&gt;2001 1 06&lt;BR /&gt;2002 1 08&lt;BR /&gt;2002 1 06&lt;BR /&gt;2002 1 06&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want separate outputs for proc freq dz*area for each year. I can subset data for each year and get the desired table for each year.&lt;/P&gt;
&lt;P&gt;data want_2000;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if year =2000 then output want_2000;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=want_2000;&lt;/P&gt;
&lt;P&gt;table dz*area;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;However, I have too many years to subset the data for each. I want to create a loop to subset each each year's data and then may be a loop to do the proc freq for each subset. Is there a way to use 'array' to be able do what I want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 21:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-to-create-multiple-outputs/m-p/728317#M226617</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-22T21:56:37Z</dc:date>
    </item>
  </channel>
</rss>

