I am wondering how to subset multiple rows in a dataset in SAS, any codes recommended? Thanks!
Take a look at the WHERE statement. That's a common tool for the task, and can be used in both DATA and PROC steps. Its chief limitation is that it must base the subsetting decisions on variables that already exist in the incoming data set.
If you need to perform calculations first, and base the subsetting on the calculated values, take a look at the IF statement. (Not IF/THEN.) It's valid in a DATA step only.
Please supply some example "have" and "want" data rows to illustrate your question.
Subsetting datasets as such is a very easy task, so you seem to have some additional requirements.
Take a look at the WHERE statement. That's a common tool for the task, and can be used in both DATA and PROC steps. Its chief limitation is that it must base the subsetting decisions on variables that already exist in the incoming data set.
If you need to perform calculations first, and base the subsetting on the calculated values, take a look at the IF statement. (Not IF/THEN.) It's valid in a DATA step only.
Another option if you wish to subset based on a list of values: use SQL inner join/sub-query with a look-up table.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.