You need to provide more details about what you are trying to do to get a better answer.
In general to execute some statements for only some of the observations you would use an IF statement.
Something like this:
data want;
set have;
if sex='M' then do;
num_births=.;
end;
run;
Another common technique to do this is to limit the number of rows read.
data want;
set have (obs = 100);
<My logic here>;
run;
yes this is what I know. but my boss said even if I have many data step for different datasets, I can just add some statement at the top and it can apply to all subsequent data steps say only 10 obs for each dataset in each data step but only need to specify once, have you heard??
You could use
options obs=10;
which will imply an (OBS=10) dataset name parameter for all datasets in a SET or MERGE statement.
Editted note: you can use this options obs= statement anywhere in the program, and it will be honored for the rest of the program until overwritten. The default value is
options obs=max;
does this include set statement inside a macro ?
@HeatherNewton wrote:
does this include set statement inside a macro ?
Try it
Although I will give you a hint ... if the macro creates valid SAS code, then the macro should run.
OBS= is a system option. Think about the meaning of "system" 😉
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.