<?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: Create Observation for a missing value. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587770#M167897</link>
    <description>one suggestion, not sure if it would work but in the second if statement do the below.&lt;BR /&gt;&lt;BR /&gt;if last_record then do;&lt;BR /&gt;enity_nm="";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;</description>
    <pubDate>Wed, 11 Sep 2019 10:04:44 GMT</pubDate>
    <dc:creator>VinitvictorCorr</dc:creator>
    <dc:date>2019-09-11T10:04:44Z</dc:date>
    <item>
      <title>Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587768#M167896</link>
      <description>&lt;P&gt;Appericiate if someone of you help me tweak the code below to&amp;nbsp;create missing value for ENITY_NM (character variable)&amp;nbsp;if there is 0 obersvation in the Input dataset 'dis_entity_id'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;752        /*extract and append ENTY_NMs based on Entity_ID*/
753        
754        data reqd_vars (drop=ENTITY_ID);
755        	set dis_entity_id end=last_record;
756        	by ENTITY_ID;
757        	length ENTY_NM $50;
758        	retain ENTY_NM;
759        	if first.ENTITY_ID then
760        	ENTY_NM=catx('/',ENTY_NM,put(ENTITY_ID, $ENTITY.));
761        	if last_record then
762        		output;
763        run;

NOTE: There were 0 observations read from the data set WORK.DIS_ENTITY_ID.
NOTE: The data set WORK.REQD_VARS has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Desired Output if the source dataset&amp;nbsp; 'dis_entity_id' has 0 bbservation,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ENTY_NM&lt;/P&gt;
&lt;P&gt;" "&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 09:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587768#M167896</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-09-11T09:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587770#M167897</link>
      <description>one suggestion, not sure if it would work but in the second if statement do the below.&lt;BR /&gt;&lt;BR /&gt;if last_record then do;&lt;BR /&gt;enity_nm="";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Sep 2019 10:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587770#M167897</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-11T10:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587771#M167898</link>
      <description>you might get the observations with missing character values&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Sep 2019 10:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587771#M167898</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-11T10:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587774#M167899</link>
      <description>&lt;P&gt;I tried and it didn't work as I got 0 observation&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 10:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587774#M167899</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-09-11T10:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587799#M167906</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp; If you have 0 obs in your dataset and want an observation with missing values, here is one easy way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if 0 then set have;
call missing(of _all_);
output;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 11:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587799#M167906</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-11T11:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587814#M167908</link>
      <description>&lt;P&gt;I tried the code as follows and ended up with error. If there is Observation in the dataset then I want to get that value in 'vars' dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2859       data vars;
2860       if 0 then set dis_entity_id;
2861       call missing(of _all_);
2862       else set dis_entity_id;
           ____
           160
ERROR 160-185: No matching IF-THEN clause.

2863       output;
2864       stop;
2865       run;

NOTE: The SAS System stopped processing this step because of errors.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 12:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587814#M167908</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-09-11T12:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587825#M167912</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp; Oh that logic is solely for zero obs dataset and please do not confuse and modify the logic like you did. Please follow the code below and see if you understand. I have written some comments to help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro check_and_do;
/*Get the number of obs in macro var N*/
proc sql noprint;
select nobs into :n trimmed
from dictionary.tables 
where libname='WORK' and memname='HAVE';
quit;

%put &amp;amp;=n;/*N is the number of obs in HAVE*/
/*Check if N&amp;gt;0*/
%if &amp;amp;n&amp;gt;0 %then %do;
 data want;
 set have;
 run;
%else %do;
/*If n=0 then do the below*/
 data want;
 if 0 then set have;
 call missing(of _all);
 output;
 stop;
 run;
 %end;
%mend check_and_do;

%check_and_do&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 13:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/587825#M167912</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-11T13:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/588121#M168041</link>
      <description>&lt;P&gt;Am I doing something wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;26         %macro check_and_do;
27         /*Get the number of obs in macro var N*/
28         proc sql noprint;
29         create table have as select nobs into :n
30         from sashelp.class;
31         quit;
32         
33         %put &amp;amp;=n;/*N is the number of obs in HAVE*/
34         /*Check if N&amp;gt;0*/
35         %if &amp;amp;n&amp;gt;0 %then %do;
36          data want;
37          set have;
38          run;
39         %else %do;
ERROR: There is no matching %IF statement for the %ELSE.
ERROR: A dummy macro will be compiled.
40         /*If n=0 then do the below*/
41          data want;
42          if 0 then set have;
43          call missing(of _all);
44          output;
45          stop;
46          run;
47          %end;
48         %mend check_and_do;
49         
50         %check_and_do
WARNING: Apparent invocation of macro CHECK_AND_DO not resolved.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Sep 2019 06:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/588121#M168041</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-09-12T06:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create Observation for a missing value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/588278#M168104</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp; &amp;nbsp;I missed to add a&lt;STRONG&gt; %end . &lt;/STRONG&gt;Sorry about that. Here is a tested sample&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
set sashelp.class(obs=0);
run;


%macro check_and_do(dsn=SAMPLE);
/*Get the number of obs in macro var N*/
proc sql noprint;
select nobs into :n trimmed
from dictionary.tables 
where libname='WORK' and memname="&amp;amp;dsn";
quit;

%put &amp;amp;=n;/*N is the number of obs in HAVE*/
/*Check if N&amp;gt;0*/
%if &amp;amp;n&amp;gt;0 %then %do;
 data want;
 set &amp;amp;dsn;
 run;
 %end;
%else %do;
/*If n=0 then do the below*/
 data want;
 if 0 then set &amp;amp;dsn;
 call missing(of _all_);
 output;
 stop;
 run;
 %end;
%mend check_and_do;

%check_and_do&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Sep 2019 14:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Observation-for-a-missing-value/m-p/588278#M168104</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-12T14:54:30Z</dc:date>
    </item>
  </channel>
</rss>

