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!).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.