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

This is simple...but I'm stumped. I have:

 

data ESRA.&month_label._&year_want; set ESRA.CURRENTMONTH; run;

 

This makes a dataset called MARCH_2019

 

I would like MARCH 2019  (note the no underscore). I have tried a bunch of different ways but I know the marco references can be a bit strange when spaces are concerned.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Don't do that.  You can put the space in the label.

data ESRA.&month_label._&year_want (label="&month_label. &year_want"); 
  set ESRA.CURRENTMONTH; 
run;

If you really want to then you will need to use a name literal.

options validmemname=extend;
data ESRA."&month_label. &year_want"n (label="&month_label. &year_want"); 
  set ESRA.CURRENTMONTH; 
run;

View solution in original post

4 REPLIES 4
Astounding
PROC Star
Nothing to do with macro language.

Data set names are not allowed to contain a blank.
Tom
Super User Tom
Super User

Don't do that.  You can put the space in the label.

data ESRA.&month_label._&year_want (label="&month_label. &year_want"); 
  set ESRA.CURRENTMONTH; 
run;

If you really want to then you will need to use a name literal.

options validmemname=extend;
data ESRA."&month_label. &year_want"n (label="&month_label. &year_want"); 
  set ESRA.CURRENTMONTH; 
run;
BCNAV
Quartz | Level 8

thanks all....I had forgotten about the space....I was asked to see if it could be done.  Cheers!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1445 views
  • 1 like
  • 4 in conversation