<?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: Show missing variable with 0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431152#M106595</link>
    <description>&lt;P&gt;use proc formats rather than if then. If then is rather tedious and boring in this case. Well, i wouldn't do it&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2018 02:02:53 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-01-26T02:02:53Z</dc:date>
    <item>
      <title>Show missing variable with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431148#M106593</link>
      <description>&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;input id days;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; 30;&lt;/P&gt;
&lt;P&gt;2 90&lt;/P&gt;
&lt;P&gt;3 115&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;/P&gt;
&lt;P&gt;set test1;&lt;/P&gt;
&lt;P&gt;if days &amp;gt;=0 and days &amp;lt;=30 then do;&amp;nbsp;range = '0-30'; else&lt;/P&gt;
&lt;P&gt;if days &amp;gt;=31 and days &amp;lt;=60 then range ='31-60'; else&lt;/P&gt;
&lt;P&gt;if days &amp;gt;=61 and days &amp;lt;=90 then range = '61-90';else&lt;/P&gt;
&lt;P&gt;if days &amp;gt;=91 and days &amp;lt;=120 then range = '91-120;&lt;/P&gt;
&lt;P&gt;cnt = 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;In this example nothing would show for the 31-60 category however in that case I want to to show 31-60 with a cnt =0 to reflect this so I can use it in a proc tabulate later on in the program.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 01:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431148#M106593</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2018-01-26T01:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Show missing variable with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431152#M106595</link>
      <description>&lt;P&gt;use proc formats rather than if then. If then is rather tedious and boring in this case. Well, i wouldn't do it&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 02:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431152#M106595</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-26T02:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Show missing variable with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431157#M106597</link>
      <description>&lt;P&gt;Deal with that within PROC TABULATE using PRELOADFMT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you search those two terms you'll find plenty of examples on how to use it. It will also save you the recoding step, since you can apply the format in PROC TABULATE directly, though you could still recode if you wanted to.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 02:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431157#M106597</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-26T02:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Show missing variable with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431197#M106609</link>
      <description>&lt;P&gt;You test data soesn't give enough informatio what you want to count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check and addapt next code to your needs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format lib=work;
value range
  low - 30 = '0-30'
   30 - 60 = '31-60' 
   60 - 90 = '61-90'
   90 - 120= '91-120'
   other = '***'
  ;
run;

data skilton;
  retain cnt 1;
  length range $6;
  range = '0-30'; output;
  range = '31-60'; output;  
  range = '61-90'; output;  
  range = '91-120'; output;
run;

data test;
input id days;
datalines;
1 30
2 90
3 115
;
run;

data test2;
set test;
    length range $6;
    range = put(days,range.);
run;
proc sort data=test2; by range; run;

data to_report;
merge skilton test2;
  by range;
  if id=. then cnt=0;
  drop days;
run;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jan 2018 09:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-missing-variable-with-0/m-p/431197#M106609</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-01-26T09:09:46Z</dc:date>
    </item>
  </channel>
</rss>

