Is there a way to check how many observations are in a SAS data set at runtime OR to detect when you’ve reached the last observation in a DATA step?
I can’t seem to find anything on the web for this seemingly simple problem. Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
nobs=option to asetstatement can give you the number of observations. When the data step is compiled, the header portion of the input datasets are scanned, so you don’t even have to execute thesetstatement in order to get the number of observations. For instance, the following reports 2 as expected:The
end=option sets a flag when the last observation (for thesetstatement) is read in.A SAS data set, however, can be a SAS data file or a SAS view. In the case of the latter, the number of observations may not be known either at compile time or at execution time.