<?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: row-wise proc freq of non empty variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916321#M41016</link>
    <description>&lt;P&gt;Because each variable contains only one word, in a DATA step you could concatenate them and count the number of words like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;  infile datalines dsd dlm='|' truncover;&lt;BR /&gt;  input D1_1:$10. D1_2:$10. D1_3:$10. D1_4:$10. D1_5:$10.;&lt;BR /&gt;datalines; &lt;BR /&gt;yellow|blue|&lt;BR /&gt;pink|yellow|magenta||black&lt;BR /&gt;magenta|orange|green&lt;BR /&gt;green|magenta|pink|white&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the frequency count by word, it's easiest to transpose with a DATA step first and then use good old PROC FREQ:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data forFreq (keep=word);
	set have;
	array w[*] D:;
	do i=1 to dim(w);
		word=w[i];
		if not cmiss(word) then output;
	end;
run;

proc freq data=forFreq;
	tables word/nocum nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Feb 2024 16:00:51 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2024-02-15T16:00:51Z</dc:date>
    <item>
      <title>row-wise proc freq of non empty variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916313#M41014</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following table:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;D1_1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1_2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D1_3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D1_4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1_5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;yellow&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;blue&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; pink&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yellow&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;magenta&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;black&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;magenta&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; orange&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&lt;/P&gt;
&lt;P&gt;green&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; magenta&amp;nbsp; &amp;nbsp; &amp;nbsp;pink&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;white&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to get row-wise the the frequency of non empty variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;let's say:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;row1:&amp;nbsp; 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;row2: 4&lt;/P&gt;
&lt;P&gt;row3: 3&lt;/P&gt;
&lt;P&gt;row4: 4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Moreover, should proc freq give me the overall frequencies of all words of the entire table although under different columns? Should I transpose the table?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;yellow: 2&lt;/P&gt;
&lt;P&gt;blue: 1&lt;/P&gt;
&lt;P&gt;pink: 2&lt;/P&gt;
&lt;P&gt;magenta: 2&lt;/P&gt;
&lt;P&gt;black: 1&lt;/P&gt;
&lt;P&gt;orange: 1&lt;/P&gt;
&lt;P&gt;green: 2&lt;/P&gt;
&lt;P&gt;white: 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 15:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916313#M41014</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-02-15T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: row-wise proc freq of non empty variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916317#M41015</link>
      <description>&lt;P&gt;For the row-wise analysis, you can use the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p1tth4ltf640din1ey86ubo2lky2.htm" target="_self"&gt;CMISS() function&lt;/A&gt;&amp;nbsp;in a SAS data step, something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;freq_of_non_miss = 5 - cmiss(of d1_1-d1_5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the second question, you would need to re-arrange the data in order to have the correct answer from PROC FREQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data re_arrange;
    set have;
    array d d1_1-d1_5;
    do i=1 to 5;
        if not missing(d(i)) then do;
             value=d(i);
             output;
         end;
    end;
    drop i d1_1-d1_5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 16:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916317#M41015</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-15T16:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: row-wise proc freq of non empty variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916321#M41016</link>
      <description>&lt;P&gt;Because each variable contains only one word, in a DATA step you could concatenate them and count the number of words like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;  infile datalines dsd dlm='|' truncover;&lt;BR /&gt;  input D1_1:$10. D1_2:$10. D1_3:$10. D1_4:$10. D1_5:$10.;&lt;BR /&gt;datalines; &lt;BR /&gt;yellow|blue|&lt;BR /&gt;pink|yellow|magenta||black&lt;BR /&gt;magenta|orange|green&lt;BR /&gt;green|magenta|pink|white&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the frequency count by word, it's easiest to transpose with a DATA step first and then use good old PROC FREQ:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data forFreq (keep=word);
	set have;
	array w[*] D:;
	do i=1 to dim(w);
		word=w[i];
		if not cmiss(word) then output;
	end;
run;

proc freq data=forFreq;
	tables word/nocum nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2024 16:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916321#M41016</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-02-15T16:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: row-wise proc freq of non empty variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916322#M41017</link>
      <description>Thank you very much!</description>
      <pubDate>Thu, 15 Feb 2024 16:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/row-wise-proc-freq-of-non-empty-variables/m-p/916322#M41017</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-02-15T16:09:14Z</dc:date>
    </item>
  </channel>
</rss>

