Date: Fri, 24 Feb 2012 11:34:02 -0500
Reply-To: Tom Abernathy <tom.abernathy@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Tom Abernathy <tom.abernathy@GMAIL.COM>
Subject: Re: Display no observations
Many people use utility macros to make this process easier. For example a
utility macro that will print a page that says "NO DATA" when the input
dataset is empty.
Here is a very simple example of this. Let's assume you have process that
first creates a dataset that you want to report. Call that data set REPORT.
Then it runs PROC PRINT or PROC REPORT or whatever to report the data from
that report. If there are 0 observations then the PROC PRINT will not
generate any output. So you just need to insert a step that only prints the
"NO DATA" page when there are 0 observations.
if nobs=0 then put 'NO DATA';
set report nobs=nobs;
On Fri, 24 Feb 2012 10:53:22 -0500, sas quest <sasquest@GMAIL.COM> wrote:
>Right now i am using the following code which is inside a macro which
>runs for multiple datasets.
> data _DSN2;
> if 0 then set _DSN1 nobs=nobs;
> if nobs=0 then do;
> call symput("nobs", "0");
> visn="NO DATA ";
>The above helps me display "NO DATA" in my output report because i
>know that the data which has no observations has a variable called
>When i run this on another study where another data say, DEATH has no
>observations, in the report "visn" doesnt exist. Variables like
>So when i run the above code my report just has blank values under
>these variables. I want to put "NO DATA" under first variable DTHDT.
>so the program should create a macro variable which stores the first
>variable name in the datasets. I can then just say &var="No DATA"
>I hope iam clear.
>On 2/24/12, Bian, Haikuo <HBian@flqio.sdps.org> wrote:
>> Not sure what exactly you are asking for, the following code will get you
>> macro variable 'var' with value of 'No observations' if the dataset is
>> data abc;
>> set xyz nobs=nobs;
>> if nobs=0 then call symput ('var','No observations');
>> %put &var;
>> -----Original Message-----
>> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of sas
>> Sent: Friday, February 24, 2012 9:58 AM
>> To: SAS-L@LISTSERV.UGA.EDU
>> Subject: Display no observations
>> I want to assign a value to a variable as "No observations" from an
>> empty dataset that changes its variables each time it is run. The
>> dataset is inside a complex macro.
>> I know many ways to create it and display it but inside the macro i
>> find it difficult................
>> i need something like this:
>> data abc;
>> set xyz;
>> /*code needed here to create var*/
>> &var="No observations";
>> The above macro variable "var" should be chosen from the datset xyz
>> which changes its variable names dynamically.
>> Thanks in advance
>> Email messages cannot be guaranteed to be secure or error-free as
>> transmitted information can be intercepted, corrupted, lost,
>> destroyed, arrive late or incomplete, or contain viruses. The
>> Centers for Medicare & Medicaid Services therefore does not accept
>> liability for any error or omissions in the contents of this
>> message, which arise as a result of email transmission.
>> CONFIDENTIALITY NOTICE: This communication, including any
>> attachments, may contain confidential information and is intended
>> only for the individual or entity to which it is addressed. Any
>> review, dissemination, or copying of this communication by anyone
>> other than the intended recipient is strictly prohibited. If you
>> are not the intended recipient, please contact the sender by reply
>> email and delete and destroy all copies of the original message.