<?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: How to output this proc freq result into a data set? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848312#M335387</link>
    <description>yes, the exact names are override_reas_1 override_reas_2 override_reas_3</description>
    <pubDate>Wed, 07 Dec 2022 11:11:13 GMT</pubDate>
    <dc:creator>SASuser4321</dc:creator>
    <dc:date>2022-12-07T11:11:13Z</dc:date>
    <item>
      <title>How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848304#M335383</link>
      <description>&lt;P&gt;I have the following table with me:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Data1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Data2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Data3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;6&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;4&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;The table has thousands of rows.&lt;/P&gt;
&lt;P&gt;I would like to know how many times each number occurs in this table. So for example, for the above table, the output of my code should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;Data_value&lt;/TD&gt;
&lt;TD width="50%"&gt;Frequency&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;3&lt;/TD&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;4&lt;/TD&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;5&lt;/TD&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;6&lt;/TD&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following but it didn't work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data transposed;
set have (Keep=data1 data2 data3);
run;

proc freq data=transposed;
tables data1 data2 data3/out=result;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last part of the above code, where I tried to output my proc freq result into a data set is the part where I was unsuccessful. Could someone help me&amp;nbsp;output this proc freq result into a data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help would be appreciated. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 10:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848304#M335383</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-12-07T10:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848305#M335384</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Data1 Data2 Data3;
infile datalines missover;
datalines;
1     
3 2   
6 3 2 
4     
5     
;

data temp(keep = data);
   set have;
   array d Data:;
   do over d;
      data = d;
      if data then output;
   end;
run;

proc freq data = temp noprint;
   tables data / out = want(drop = percent);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data  COUNT
1     1
2     2
3     2
4     1
5     1
6     1&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848305#M335384</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848309#M335385</link>
      <description>&lt;P&gt;Thank you for your comment. Unfortunately, it didn't work for me. Here is the log source:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1569  data temp(keep = data);
1570     set app_port (Keep=override_reas_1 override_reas_2 override_reas_3);
1571     array d Data:;
WARNING: Defining an array with zero elements.
1572     do over d;
1573        data = d;
1574        if data then output;
1575     end;
1576  run;

NOTE: Compression was disabled for data set WORK.TEMP because compression overhead would increase the size of the data set.
NOTE: There were 8225 observations read from the data set WORK.APP_PORT.
NOTE: The data set WORK.TEMP has 0 observations and 1 variables.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848309#M335385</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-12-07T11:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848311#M335386</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436771"&gt;@SASuser4321&lt;/a&gt;&amp;nbsp;is your data representative? Are the names of the columns 'Data1', 'Data2' and so on really Override1 and&amp;nbsp;Override2 and so on?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848311#M335386</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848312#M335387</link>
      <description>yes, the exact names are override_reas_1 override_reas_2 override_reas_3</description>
      <pubDate>Wed, 07 Dec 2022 11:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848312#M335387</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-12-07T11:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848314#M335388</link>
      <description>&lt;P&gt;Then simply change the names of the variables like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input override_reas_1 override_reas_2 override_reas_3;
infile datalines missover;
datalines;
1     
3 2   
6 3 2 
4     
5     
;

data temp(keep = override);
   set have;
   array o override_reas_:;
   do over o;
      override = o;
      if override then output;
   end;
run;

proc freq data = temp noprint;
   tables override / out = want(drop = percent);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848314#M335388</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848315#M335389</link>
      <description>&lt;P&gt;You need to use the REAL variable names in your code and not the made-up variable names in your original problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better would be to use the REAL variable names in your original problem statement, and this avoids this issue entirely.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848315#M335389</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-07T11:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848316#M335390</link>
      <description>&lt;P&gt;Thank you. It works now.&amp;nbsp;Could you please explain what each line of the following code does?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array o override_reas_:;
   do over o;
      override = o;
      if override then output;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848316#M335390</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-12-07T11:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to output this proc freq result into a data set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848317#M335391</link>
      <description>&lt;P&gt;Great.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure thing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array o override_reas_:; /* Create an array of all variables prefixed with oerride_reas_ */
   do over o; /* For each variable in o do.. */
      override = o; /* Set the variable override to the value of the current value of the array */
      if override then output; /* Too avoid missing values in the output data, output only if override is not missing */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-this-proc-freq-result-into-a-data-set/m-p/848317#M335391</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:20:29Z</dc:date>
    </item>
  </channel>
</rss>

