BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jaliu
Quartz | Level 8

Is there a reason I cannot use both the rename and in options? Or how can i fix the syntax?

 

data test;
merge stormbasin (rename=(BasinCode=Basin))(in=code) stormsum (in=sum);
if code=1;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@jaliu wrote:

Is there a reason I cannot use both the rename and in options? Or how can i fix the syntax?

 

data test;
merge stormbasin (rename=(BasinCode=Basin))(in=code) stormsum (in=sum);
if code=1;

All data set options for a specific set appear within one set of ().

Try

data test;
merge stormbasin (rename=(BasinCode=Basin)  in=code) stormsum (in=sum);
if code=1;

Your code with the second ) after Basin ended the options for Stormbasin and the (in=code) wasn't valid as there was no data set associated with the option.

Your code would have generated an error similar to the one here:

759  data junk;
760     set sashelp.class (rename=(sex=gender)) (in=code);
                                                -
                                                22
                                                76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.

ERROR 76-322: Syntax error, statement will be ignored.

761  run;

The underscore under the ( says that character wasn't expected and most of the expected things listed are SET options which would be a clue that you have left data set options behind.

 

View solution in original post

6 REPLIES 6
sbxkoenk
SAS Super FREQ

Use one pair of brackets to specify the data set options (rename= and in=).

 

data test;
merge stormbasin (rename=(BasinCode=Basin) in=code) 
      stormsum   (in=sum);
if code=1;

Koen

ballardw
Super User

@jaliu wrote:

Is there a reason I cannot use both the rename and in options? Or how can i fix the syntax?

 

data test;
merge stormbasin (rename=(BasinCode=Basin))(in=code) stormsum (in=sum);
if code=1;

All data set options for a specific set appear within one set of ().

Try

data test;
merge stormbasin (rename=(BasinCode=Basin)  in=code) stormsum (in=sum);
if code=1;

Your code with the second ) after Basin ended the options for Stormbasin and the (in=code) wasn't valid as there was no data set associated with the option.

Your code would have generated an error similar to the one here:

759  data junk;
760     set sashelp.class (rename=(sex=gender)) (in=code);
                                                -
                                                22
                                                76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.

ERROR 76-322: Syntax error, statement will be ignored.

761  run;

The underscore under the ( says that character wasn't expected and most of the expected things listed are SET options which would be a clue that you have left data set options behind.

 

jaliu
Quartz | Level 8

is it possible that options require () only when we can list multiple data sets next to eachother without a semicolon? i.e. if there would no be no confusion (and this goes for other statements as well) then the syntax wouldn't require ()?

sbxkoenk
SAS Super FREQ

Hello @jaliu ,

 

Data set options always require one set of (), regardless how many data sets are specified before the semicolon. So, if there's only one dataset you also need the ().

 

Koen

jaliu
Quartz | Level 8

maybe you are misunderstanding my question. I want to know why sometimes we need () for options and sometimes we don't. 

sbxkoenk
SAS Super FREQ

Hello,

 

Data set options always need a (one) set of round brackets and the options should be specified within the ().

 

I agree you can do something like:

data _null_;
set have nobs=nobs point=nobs;
call symputx('yymm',yymm);
stop;
run;

but, here, nobs= and point= are no data set options but rather data STEP options.

 

Kind regards,

Koen

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1599 views
  • 2 likes
  • 3 in conversation