Date: Wed, 3 Oct 2007 12:08:22 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: proc print output in case of 0 observation
On Wed, 3 Oct 2007 07:47:16 -0500, data _null_, <datanull@GMAIL.COM> wrote:
>This can be accomplished. You need a data step that detects when you
>have 0 observations and creates a record that can be printed to
>produce the column headings. And when there are observations does not
>create the record with all missing values. Consider the following.
>
>data work.class;
> set sashelp.class;
> if age eq 1; *no one has age 1, so you get 0 observations;
> run;
>data work.classV / view=work.classV;
> if nobs eq 0 then link OneMissingRecord;
> set work.class nobs=nobs;
> output;
> return;
>OneMissingRecord:
> output;
> return;
> run;
>proc print data=work.classV;
> run;
>
>On 10/3/07, Ankur <jainankur@gmail.com> wrote:
>> Hi
>>
>> I have a dataset that I am trying to display using proc print. Since,
>> the dataset doesn't have any observation, proc print doesn't print
>> anything, not even the column headers. Could anyone explain how to use
>> proc print or any other method of displaying the column headers as the
>> output.
>>
>> Say, dataset is test_dt;
>> +-------------+------------+
>> column_a +column_b
>> +-------------+------------+
>> + + +
>> +-------------+------------+
>>
>> I want to display the headers as the output.
>>
>> ------------------------------
>> column_a+column_b
>> ------------------------------
>>
>> Could someone provide some help?
>>
>>
>> Regards
>> Ankur Jain
>>
>> http://ankurjain.org
>>
Here's a way which does not depend on NOBS= (which is not always available
and accurate) and which displays absolutely nothing below the column headings.
data complement;
if done then output;
set class end=done;
stop;
run;
options missing='';
proc print data=complement noobs;
run;
options missing=.;
proc print data=class;
run;
Either the original data set (CLASS) or COMPLEMENT will be empty, but not both.
|