BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
What is the command to run the transformation (within a data step)
To only a small no of rows?
7 REPLIES 7
Tom
Super User Tom
Super User

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;
SASKiwi
PROC Star

Another common technique to do this is to limit the number of rows read.

data want;
  set have (obs = 100);
 <My logic here>;
run;

 

HeatherNewton
Quartz | Level 8

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??

mkeintz
PROC Star

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;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
HeatherNewton
Quartz | Level 8

does this include set statement inside a macro ?

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 402 views
  • 2 likes
  • 6 in conversation