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 (October 1996, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 28 Oct 1996 09:28:29 +0500
Reply-To:     Bernard Tremblay <bernard@CAPITALE.QC.CA>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Bernard Tremblay <bernard@CAPITALE.QC.CA>
Subject:      Re: Help with Data Step processing
Comments: To: gopinath@API.ORG

Hi,

I have a simple macro that put the number of observation in the macro variable "NBR". Your may want to use it... Or simply use the dataset option "nobs=variable" in your "set" statement...

/*------------------------------------------------------------------*/;

%macro numobs(fi); %global nbr; data _null_; dsid=open("&fi","i"); if ^dsid then do;msg=sysmsg();put "error: fichier &fi :" msg ;end; nobs=attrn(dsid,"nobs"); dsid=close(dsid); call symput ('nbr',left(put(nobs,8.))); stop; run; %mend numobs; /*------------------------------------------------------------------*/;

\\\|/// \\ - - // ( @ @ ) +------oOOo-(_)-oOOo----------+---------------------------------+ | Bernard Tremblay | Bureau: (418) 646-2401 | | La Capitale | Maison: (418) 878-4447 | | |Internet: bernard@capitale.qc.ca | | | bertrem@quebectel.com | +---------------Oooo----------+---------------------------------+ oooO ( ) ( ) ) / \ ( (_/ \_)

>>>From owner-sas-l@UGA.CC.UGA.EDU Fri Oct 25 17:33 EDT 1996 >>>Mr-Received: by mta BULWKL.MUAS; Relayed; Fri, 25 Oct 1996 17:26:43 -0400 >>>Mr-Received: by mta ROCKY2; Relayed; Fri, 25 Oct 1996 17:26:46 -0400 >>>Alternate-Recipient: prohibited >>>Disclose-Recipients: prohibited >>>Autoforwarded: false >>>Mime-Version: 1.0 >>>Content-Transfer-Encoding: 7BIT >>>Importance: normal >>>X400-Mts-Identifier: [;0643261725101996/A23228/ROCKY2] >>>Hop-Count: 1 >>>Date: Fri, 25 Oct 1996 17:26:43 -0400 >>>From: GOPINATH <gopinath@API.ORG> >>>Subject: Help with Data Step processing >>>To: Multiple recipients of list SAS-L <SAS-L@UGA.CC.UGA.EDU> >>> >>>Dear SAS-Lers, >>> >>>I am trying to do the following: I have to read in a SAS dataset which >>> has 'n' observations and then delete the last 3 observations. For >>> example, if my dataset has 100 observations, I have to delete the 100th, >>> 99th and 98th observations. I have to do this several times and the >>> number of observations 'n' varies each time. >>> >>> Is there a simple way to calculate the the total number of observations >>> in a dataset and assign this value to a variable? It seems to be a >>> simple problem but I haven't figured out a way of doing it. >>> >>>Any help would be much appreciated. >>> >>>Thanks in advance. >>> >>> >>>Amita Gopinath >>>Gopinath@api.org


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