LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 16 Feb 1996 16:50:54 -0500
Reply-To:   Mark Dalesandro <dalesam@HLTHSRC.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   Mark Dalesandro <dalesam@HLTHSRC.COM>
Subject:   Re: Counting the # of variables in a SAS dataset -Reply
Comments:   To: 100013.1673@COMPUSERVE.COM

another way to get such dataset info is with dictionary.tables

you might try:

proc sql noprint; select (NOBS-DELOBS+0) into:number from %str(dictionary.tables) where libname="LIBNAME" and memname="DSNAME"; quit;

&number will now hold the number of obs.

Regards, Mark Dalesandro dalesam@hlthsrc.com

>>> Ruedi P. Weinmann <100013.1673@COMPUSERVE.COM> 02/14/96 12:51am >>> 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. */


Back to: Top of message | Previous page | Main SAS-L page