Hi,
I need to print a count (no. of observations) of a file in a particular field.
How I can achieve that?
Can I use NOOBS to print in any new field?
Thanks
Please supply some example data (in a data step with datalines), and what you expect out of it.
noobs is an option for proc print. It will print the observation number in the output.
If you want to create a simple observation count, use _n_ in a data step.
Hi,
I'm a little unclear about what you mean by "particular field" and "any new field"; I have assumed that by "file" you mean "SAS data set". Are you trying to create a separate SAS data set that contains the count of observations from another SAS data set? Do you just want to see the count displayed in the log? E.g.:
data _null_;
put count =;
set sashelp.class(obs=0) nobs = count;
run;
Please clarify what you require, thanks.
Regards,
Amir.
My file has 5000+ records and I want this no. to be printed in a new file with the records count.
Something like:
proc print data=sashelp.vtable; var nobs; where libname="<yourlib>" and memname="<yourds>"; run;
Note that <yourlib> and <yourds> need to be replaced with your library and dataset names (note most probably in upper case!).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: