I want to show some specific obs from a dataset with Proc Print
Ex-- we have a dataset which contains name with different Genders.
I want to print only Gender = M obs with Proc Print, we can use Where condition.But if i don't want to print all obs but some specific number (For Ex-2 -- only x and Y not Z)
How to do it?
If you want the first n observations of a specific subset, it is much easier to use SQL with the OUTOBS option:
Proc sql outoubs=20; select name from have where gender='M'; quit;
You may want to use ORDER BY to make sure you get the topmost observations, SQL does not guarantee the order otherwise.
Are you trying to control the number of records to print or you want to print the list of record that you wish?
If you have a list where your print result need to include from then, Why not list them in where condition. Create a list of values into a macro and then later filter them in Proc print where condition.
proc sql noprint; select quote(strip(name)) into:names separated by ',' from sashelp.class where age>13; quit; proc print data=sashelp.class(where=(sex='M' and name in (&names.))); run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.