<?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: Help with if/else statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309696#M66722</link>
    <description>&lt;P&gt;Post exactly what you are doing, trying to do. &amp;nbsp;I don't see why you wouldn't just access the sashelp.vtable metadata information directly:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="WORK" and memname="TOTAL_ROD_W"));
  call symput('Count',nobs);
run;&lt;/PRE&gt;
&lt;P&gt;Not that I am entirely sure why you would want to put number of observations into a macro variable in the first place, that sounds like your whole process is a bit off.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Nov 2016 12:06:02 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-11-07T12:06:02Z</dc:date>
    <item>
      <title>Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309689#M66719</link>
      <description>&lt;P&gt;Trying to add a functionalty of writing 0 Count if there are no observations. However it fails on the second else if statement and runs if the else if is commented away....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc freq data=reason ; table remove /out=total_rød_w missing nocol nocum norow nosparse ;


;
run;
Proc datasets nolist;
     contents DATA=work.total_rød_w out=temp(Keep=NOBS) noprint;
run;
Data check;
     Set temp total_rød_w;
     If NOBS = 0 Then do;
			CALL SYMPUT ('Count',PUT(0,10.0));
	 else if NOBS = 1 Then do;
	 		CALL SYMPUT ('Count',PUT(Count,10.0));
	 end;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Nov 2016 11:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309689#M66719</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-11-07T11:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309692#M66720</link>
      <description>&lt;P&gt;a) you use nobs, but I guess it is never defined, because there is no nobs= option in the set statement.&lt;/P&gt;
&lt;P&gt;b) your first then do misses its corresponding end:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
set temp total_red_w; * changed because of special character not allowed in SAS name;
if NOBS = 0
then do;
  call symput ('count',put(0,10.0));
end; * this is missing in your code;
else if NOBS = 1
then do;
  call symput ('count',put(Count,10.0));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For further help, post the log of the data step.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 11:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309692#M66720</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-07T11:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309695#M66721</link>
      <description>&lt;P&gt;If that's the sole objective, you can simplify the problem considerably:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;call symputx('count', '0');&lt;/P&gt;
&lt;P&gt;set total_rod_w nobs=_nobs_;&lt;/P&gt;
&lt;P&gt;call symputx('count', _nobs_);&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you actually want the same DATA step to write the report when there are 0 observations, slight modifications can make that happen.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 12:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309695#M66721</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-11-07T12:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309696#M66722</link>
      <description>&lt;P&gt;Post exactly what you are doing, trying to do. &amp;nbsp;I don't see why you wouldn't just access the sashelp.vtable metadata information directly:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="WORK" and memname="TOTAL_ROD_W"));
  call symput('Count',nobs);
run;&lt;/PRE&gt;
&lt;P&gt;Not that I am entirely sure why you would want to put number of observations into a macro variable in the first place, that sounds like your whole process is a bit off.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 12:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309696#M66722</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-07T12:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309697#M66723</link>
      <description>&lt;P&gt;I just changed it a bit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx('count', '0');
set pande_total_rød_w nobs=_nobs_;
call symputx('count', COUNT);
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;looks like a top soloution&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 12:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309697#M66723</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-11-07T12:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309698#M66724</link>
      <description>&lt;P&gt;I am using that number in an email report&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 12:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309698#M66724</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-11-07T12:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309701#M66726</link>
      <description>&lt;P&gt;You can do something like that, but you have to use the right variable name. &amp;nbsp;If you want to use COUNT as the variable name in CALL SYMPUTX, you would have to code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set have nobs=count;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 12:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309701#M66726</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-11-07T12:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if/else statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309702#M66727</link>
      <description>&lt;P&gt;In which case drop the whole macro var bit and just do:&lt;/P&gt;
&lt;PRE&gt;filename mymail ...;
data _null_;
  set set pande_total_rød_w nobs=_nobs_;
  file mymail;
  if _n_=1 then do;
    put "Number of observations: " _nobs_;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Nov 2016 12:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-if-else-statement/m-p/309702#M66727</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-07T12:31:24Z</dc:date>
    </item>
  </channel>
</rss>

