Date: Thu, 4 Oct 2007 07:43:32 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: proc print output in case of 0 observation
I can't imagine that you can use proc print or any other proc to print
only the headers of a 0-obs dataset. I think, one solution could be a
macro to get something like that.
%macro print;
%let nobs=0;
data _null_;
set something;
call symput("nobs",_n_);
run;
%if &nobs=0 %then %do;
the action you want to use with 0 obs. E.g. produce a dataset with 1
empty obs (missing values). To get no dots for nums, you could use the
missing=" " option.
Or use a DATA _NULL_; step to print what you want.
%end;
%else %do;
proc print....;
run;
%end;
%mend; %print;
don't forget to initialize the &nobs, because the CALL SYMPUT is never
executed if the dataset "something" is empty!
Gerhard
On Thu, 4 Oct 2007 06:46:46 -0400, Jim Groeneveld <jim4stat@YAHOO.CO.UK>
wrote:
>Hi Ankur,
>
>If you have a dataset with a selection query (a WHERE dataset option)
which
>results in 0 observations selected you can't use NOBS as that will return
>the observations in the dataset without applying the selection query.
>
>in that case you just have to initially read the dataset in a _NULL_
>datastep and count the records passed. Alternatively you can create
another
>dataset being the subset (with possibly 0 observations) of the first one
and
>process the second one as already indicated.
>
>Regards - Jim.
>--
>Jim Groeneveld, Netherlands
>Statistician, SAS consultant
>home.hccnet.nl/jim.groeneveld
>
>
>On Wed, 3 Oct 2007 03:59:43 -0700, 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
|