| Date: | Wed, 14 Feb 1996 05:51:16 GMT |
| Reply-To: | "Ruedi P. Weinmann" <100013.1673@COMPUSERVE.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | "Ruedi P. Weinmann" <100013.1673@COMPUSERVE.COM> |
| Organization: | Zuercher Kantonalbank, Zurich, Switzerland |
| Subject: | Re: Counting the # of variables in a SAS dataset |
|---|
Steven Hill <steven.hill@SFWMD.GOV> wrote:
>Hi Netters:
>Is there a way to count the number of variables a SAS dataset contains?
>If so, does anyone have the code to do this?
>Thanks,
>Steven
Sas Language page 485:
NOBS=variable-name
creates and names a temporary variable whose value is usually the
total number of observations in the input data set or data sets. If
more than one data set is listed in the SET statement, the value of
the NOBS= variable is the total number of observations in the data
sets listed. At compilation time, the SAS System reads the descriptor
portion of each data set and assigns the value of the NOBS= variable
before the SET statement. The variable is available in the DATA step
but is not added to the new data set. The NOBS= and POINT= options are
independent of each other:
For certain SAS views, the SAS System cannot determine the number of
observations. In these cases, the SAS System sets the value of the
NOBS= variable to the largest positive integer available on the host
system.
%local obscnt;
%macro countobs(dsn)
data _null_;
set &dsn(obs=1) NOBS=obscnt;
call symput('obscnt',obscnt);
run;
%mend countobs;
%put Number of oservations = &obscnt ;
regards
/* Rudolf Paul Weinmann */
/* Senior Analyst-Programmer */
/* Zuercher Kantonalbank, PO Box */
/* 8010 Zurich, Switzerland */
/* E-Mail: 100013.1673@compuserve.com */
/* Voice : +41 1 275 8097 */
/* These are my views and opinions */
/* and not necessarily those of */
/* Zuercher Kantonalbank. */
|