<?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 proc freq output to data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929703#M365791</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to calculate for each numeric variable-&lt;/P&gt;
&lt;P&gt;number of rows with null values&lt;/P&gt;
&lt;P&gt;number of rows with zero values&lt;/P&gt;
&lt;P&gt;number of rows with positive values&lt;/P&gt;
&lt;P&gt;number of rows with negative&amp;nbsp; values that not null&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want that the output will be out to a data set&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't see the desired output&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1716709322155.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96772iD53E5D733F5AA65A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1716709322155.png" alt="Ronein_0-1716709322155.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I also want to ask about the user format I have defined.&lt;/P&gt;
&lt;P&gt;Is null value not included in both groups??&lt;/P&gt;
&lt;P&gt;. ='Missing' &lt;BR /&gt;Low-&amp;lt;0='Neg'&lt;/P&gt;
&lt;P&gt;I want that null be only in first group&amp;nbsp; (. ='Missing')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input x y z R $;
cards;
1 2 0 a
3 0 -2 b
. 3 3 c
. . . r
4 4 4 e
4 4 0 f
-1 -1 -1 g
;
run;

proc format;
value  numeric_Fmt 
. ='Missing' 
0='Zero'
0&amp;lt;-High='POS'
Low-&amp;lt;0='Neg'
;
run;
 
proc freq data=have; 
format _NUMERIC_ numeric_Fmt.;
tables _NUMERIC_ /out=want missing missprint nocum nopercent;
run;
&lt;/CODE&gt;&lt;/PRE&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>Sun, 26 May 2024 07:44:21 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2024-05-26T07:44:21Z</dc:date>
    <item>
      <title>proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929703#M365791</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to calculate for each numeric variable-&lt;/P&gt;
&lt;P&gt;number of rows with null values&lt;/P&gt;
&lt;P&gt;number of rows with zero values&lt;/P&gt;
&lt;P&gt;number of rows with positive values&lt;/P&gt;
&lt;P&gt;number of rows with negative&amp;nbsp; values that not null&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want that the output will be out to a data set&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't see the desired output&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1716709322155.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96772iD53E5D733F5AA65A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1716709322155.png" alt="Ronein_0-1716709322155.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I also want to ask about the user format I have defined.&lt;/P&gt;
&lt;P&gt;Is null value not included in both groups??&lt;/P&gt;
&lt;P&gt;. ='Missing' &lt;BR /&gt;Low-&amp;lt;0='Neg'&lt;/P&gt;
&lt;P&gt;I want that null be only in first group&amp;nbsp; (. ='Missing')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input x y z R $;
cards;
1 2 0 a
3 0 -2 b
. 3 3 c
. . . r
4 4 4 e
4 4 0 f
-1 -1 -1 g
;
run;

proc format;
value  numeric_Fmt 
. ='Missing' 
0='Zero'
0&amp;lt;-High='POS'
Low-&amp;lt;0='Neg'
;
run;
 
proc freq data=have; 
format _NUMERIC_ numeric_Fmt.;
tables _NUMERIC_ /out=want missing missprint nocum nopercent;
run;
&lt;/CODE&gt;&lt;/PRE&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>Sun, 26 May 2024 07:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929703#M365791</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-05-26T07:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929708#M365792</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;.z&amp;lt;-&amp;lt;0='Neg'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 May 2024 10:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929708#M365792</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-05-26T10:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929718#M365798</link>
      <description>&lt;P&gt;Error&lt;/P&gt;
&lt;P&gt;ERROR: Cannot mix missing and nonmissing values in the same range: Z&amp;lt;-&amp;lt;0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

proc format;
value  numeric_Fmt 
. ='Missing' 
0='Zero'
0&amp;lt;-High='POS'
.z&amp;lt;-&amp;lt;0='Neg'
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 May 2024 11:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929718#M365798</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-05-26T11:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929719#M365799</link>
      <description>&lt;P&gt;What about the problem that I cannot see the desired output in the wanted data set?&lt;/P&gt;
&lt;P&gt;I want to see for each numeric variable -&lt;/P&gt;
&lt;P&gt;nr rows with zero value&lt;/P&gt;
&lt;P&gt;nr rows with pos value&lt;/P&gt;
&lt;P&gt;nr rows with neg value&lt;/P&gt;
&lt;P&gt;nr rows with null value&lt;/P&gt;</description>
      <pubDate>Sun, 26 May 2024 11:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929719#M365799</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-05-26T11:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929720#M365800</link>
      <description>&lt;P&gt;You are asking to create VARIABLES named Missing, Neg, Pos and zero. So assigning a format alone will not do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this were my project:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input x y z R $;
cards;
1 2 0 a
3 0 -2 b
. 3 3 c
. . . r
4 4 4 e
4 4 0 f
-1 -1 -1 g
;
run;

proc format;
value  numeric_Fmt 
. ='Missing' 
0='Zero'
0&amp;lt;-High='POS'
Low-&amp;lt;0='Neg'
;
run;

data helpful;
   set have;
   array a(*) _numeric_;
   do i=1 to dim(a);
      var=vname(a[i]);
      value=put(a[i],numeric_fmt. -L);
      output;
   end;
run;

Proc freq data=helpful noprint;
   tables var*value/out=counts nocum nopercent;
run;

proc transpose data=counts out=want (drop=_name_ _label_) ;
  by var notsorted;
  id value;
  var count;
run;
      &lt;/PRE&gt;</description>
      <pubDate>Sun, 26 May 2024 12:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929720#M365800</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-26T12:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929725#M365802</link>
      <description>Thanks. What about my question  regarding format of null value? Is null value not included in 2 different groups??&lt;BR /&gt;. ='Missing' &lt;BR /&gt;Low-&amp;lt;0='Neg'&lt;BR /&gt;&lt;BR /&gt;As far as I know null in sas is negative</description>
      <pubDate>Sun, 26 May 2024 13:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929725#M365802</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-05-26T13:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929726#M365803</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What about the problem that I cannot see the desired output in the wanted data set?&lt;/P&gt;
&lt;P&gt;I want to see for each numeric variable -&lt;/P&gt;
&lt;P&gt;nr rows with zero value&lt;/P&gt;
&lt;P&gt;nr rows with pos value&lt;/P&gt;
&lt;P&gt;nr rows with neg value&lt;/P&gt;
&lt;P&gt;nr rows with null value&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This was answered by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; in a question you asked on April 17. &lt;A href="https://communities.sas.com/t5/SAS-Programming/proc-freq-one-way-table-for-multiple-vars-export-to-data-set/m-p/924730#M363982" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/proc-freq-one-way-table-for-multiple-vars-export-to-data-set/m-p/924730#M363982&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as the format problem is concerned, you could replace .z with some lower number that the data will never exceed, such as -999999. Or if that is absolutely unknown, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value numeric_Fmt 
._-.z ='Missing' 
0='Zero'
0&amp;lt;-High='POS'
other='Neg'
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please stop showing us partial logs. When there is an ERROR, we want to see the log for that PROC or DATA step, including the code as it appears in the log, including all errors and warnings, that are in the log for that PROC or DATA step. We have asked you to stop doing this before, and you continue to do it.&lt;/P&gt;</description>
      <pubDate>Sun, 26 May 2024 13:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929726#M365803</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-05-26T13:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq output to data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929735#M365804</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks. What about my question regarding format of null value? Is null value not included in 2 different groups??&lt;BR /&gt;. ='Missing' &lt;BR /&gt;Low-&amp;lt;0='Neg'&lt;BR /&gt;&lt;BR /&gt;As far as I know null in sas is negative&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No.&amp;nbsp; I suspect you are thinking about how the inequality operator works.&amp;nbsp; But PROC FORMAT has its own rules.&amp;nbsp; In PROC FORMAT range of values definitions LOW is the the smallest non-missing value.&amp;nbsp; So missing is not included in your 'Neg' range.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you have another problem because you do not assign any display label for any of the other 27 possible missing values.&amp;nbsp; So .Z will display as 'Z' instead of as 'Missing' since it is not included in any of your ranges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try a format like this instead and all 28 missing values will be labeled as Missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
 value sign low-&amp;lt;0 = 'Negative'
       0 = 'Zero'
       0&amp;lt;-high = 'Positive'
       other = 'Missing'
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 May 2024 16:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-output-to-data-set/m-p/929735#M365804</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-26T16:16:18Z</dc:date>
    </item>
  </channel>
</rss>

