<?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: Count of non-zero observations for numerous variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216063#M53160</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, in that case ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is little to change about the PROC MEANS.&amp;nbsp; It can run on your original data set, but does not require the N statistic as part of the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FREQ can generate the counts, but it would probably be easier to use a DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have end=done;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array in {160} var1-var160;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array out {160} count1-count160;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; retain count1-count160 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _i_=1 to 160;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if in{_i_} not in (., 0) then out{_i_} + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if done;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; keep count1-count160;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So already the code gets a bit complex.&amp;nbsp; Then there is the requirement to combine both sets of results, which uses perhaps more complex tools.&amp;nbsp; How comfortable are you with complex code?&amp;nbsp; Would you prefer to drop the requirement about just counting the non-zeros?&amp;nbsp; Either path is possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Aug 2015 01:27:48 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-08-04T01:27:48Z</dc:date>
    <item>
      <title>Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216059#M53156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Company&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;VAR1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;VAR2&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="color: #ffffff; font-size: 13.3333330154419px; text-align: center; background-color: #6690bc;"&gt;VAR3&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="color: #ffffff; font-size: 13.3333330154419px; text-align: center; background-color: #6690bc;"&gt;VAR4&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="color: #ffffff; font-size: 13.3333330154419px; text-align: center; background-color: #6690bc;"&gt;VAR5&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Company1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;28&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Company2&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Company3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;55&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Company4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;8&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;23&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Company5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;34&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;52&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dataset has a total of 160 variables, of which I want to find summary statistics for each variable. However, I first want to determine the number of non-zero observations for each variable. To do this with a small number of variables I would probably do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select *, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(case when VAR1 ne 0 then 1 else 0 end) as count1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(case when VAR2 ne 0 then 1 else 0 end) as count2&lt;/P&gt;&lt;P&gt; from have;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, this is code is not as useful when I have 160 variables I want to get counts for. Is there an easier way this can be done? I assume this can be done with proc freq or proc summary, but am not very familiar with these procs. Keep in mind I also want to keep the values for each variable as I want to eventually gather summary statistics for each variable. Eventually I would want my final dataset to look something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Variable&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Number of non-zero observations for each variable&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Min&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Max&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Mean&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Median&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var6&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...etc.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Var7&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...etc.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can probably handle the transposing and re-arranging the data from a proc means output, so I was mostly wondering what the best way to get the count of non-zero observations for each variable.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 20:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216059#M53156</guid>
      <dc:creator>ttatum</dc:creator>
      <dc:date>2015-08-03T20:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216060#M53157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are ways to do this, but first you have to clarify what you want.&amp;nbsp; Are the Min, Max, Mean, and Median supposed to be based on the non-zero values only?&amp;nbsp; That's the easiest case of all.&amp;nbsp; Just change all zeros to missing values:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array vars {160} var1-var160;&lt;/P&gt;&lt;P&gt;do _i_=1 to 160;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if vars{_i_}=0 then vars{_i_}=.;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc means data=want n min max mean median;&lt;/P&gt;&lt;P&gt;var var1-var160;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want statistics to include all the zeros, that will take a little more work, but is still fairly easy.&amp;nbsp; So what are you looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 22:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216060#M53157</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-08-03T22:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216061#M53158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And by non- zero do you have an negative values to consider?&lt;/P&gt;&lt;P&gt;If you want a count one way is a custom format and proc freq/report/tabulate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value nonzero&lt;/P&gt;&lt;P&gt;0='Zero'&lt;/P&gt;&lt;P&gt;0&amp;lt;-high = 'Nonzero'&amp;nbsp; /* assumes all the non-zero values of interest are positive*/&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data= have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables _numeric_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format _numeric_ nonzero.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Or any list of variables will work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 23:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216061#M53158</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-03T23:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216062#M53159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the response. I would like to include any zero or negative values in my summary statistics, but have a count of how many observations were not equal to zero for each variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 23:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216062#M53159</guid>
      <dc:creator>ttatum</dc:creator>
      <dc:date>2015-08-03T23:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216063#M53160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, in that case ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is little to change about the PROC MEANS.&amp;nbsp; It can run on your original data set, but does not require the N statistic as part of the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FREQ can generate the counts, but it would probably be easier to use a DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have end=done;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array in {160} var1-var160;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array out {160} count1-count160;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; retain count1-count160 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _i_=1 to 160;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if in{_i_} not in (., 0) then out{_i_} + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if done;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; keep count1-count160;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So already the code gets a bit complex.&amp;nbsp; Then there is the requirement to combine both sets of results, which uses perhaps more complex tools.&amp;nbsp; How comfortable are you with complex code?&amp;nbsp; Would you prefer to drop the requirement about just counting the non-zeros?&amp;nbsp; Either path is possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 01:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216063#M53160</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-08-04T01:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216064#M53161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe &lt;SPAN class="j-post-author "&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="5253" data-username="Astounding" href="https://communities.sas.com/people/Astounding" id="jive-525354028569676665186"&gt;Astounding&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp; has provided you the right answer. The below will generate the output similar to &lt;SPAN class="j-post-author "&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="2333" data-externalid="" data-presence="null" data-userid="260198" data-username="ballardw" href="https://communities.sas.com/people/ballardw" id="jive-26019854028569688196186"&gt;ballardw&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; but only nonzero obs count. Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input Company$&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR1&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR2&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR3&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR4&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;Company1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;Company2&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp; 19&lt;/P&gt;&lt;P&gt;Company3&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 55&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&lt;/P&gt;&lt;P&gt;Company4&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 23&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/P&gt;&lt;P&gt;Company5&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 34&amp;nbsp;&amp;nbsp;&amp;nbsp; 52&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set data1;&lt;/P&gt;&lt;P&gt;array cnt col1-col99;&lt;/P&gt;&lt;P&gt;array cnts cols1-cols99;&lt;/P&gt;&lt;P&gt;do over cnt;&lt;/P&gt;&lt;P&gt;if cnt in (0,.) then cnts=1;&lt;/P&gt;&lt;P&gt;else cnts=.;&lt;/P&gt;&lt;P&gt;allcnts=nmiss(of cols1-cols99);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop col: cols:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 01:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216064#M53161</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-08-04T01:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Count of non-zero observations for numerous variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216065#M53162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. This should work. I can probably get my data into the final desired format from the code provided by you and ballerdw + Jag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 02:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-of-non-zero-observations-for-numerous-variables/m-p/216065#M53162</guid>
      <dc:creator>ttatum</dc:creator>
      <dc:date>2015-08-04T02:05:32Z</dc:date>
    </item>
  </channel>
</rss>

