BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ccaudillo100
Obsidian | Level 7

Hello,

 

Currently I am trying to plug in the parameter midword and was wondering if anyone had any advice. I will attach the code below

 

%Let Num = 2

Proc SQL; 
Create Table Test as 
Select Name&NumFull,
Year&NumLast
From xx;
Quit;

Ideally the columns that would be selected would be Name2Full and Year2Last. 

 

Currently this is not working and it just trying to pull columns with the same exact names typed. I have tried " " and ' ' around them and it does not work. Any advice would be much appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this instead.

 

This is a classic example of when to use the dot (.) de delimit macro variables. In your code, SAS looks for the macro variables &NumFull and &NumLast in the symbol tables. You want SAS to look for the macro variable &Num 🙂

 

%Let Num = 2

Proc SQL; 
Create Table Test as 
Select Name&Num.Full,
Year&Num.Last
From xx;
Quit;

 

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Try this instead.

 

This is a classic example of when to use the dot (.) de delimit macro variables. In your code, SAS looks for the macro variables &NumFull and &NumLast in the symbol tables. You want SAS to look for the macro variable &Num 🙂

 

%Let Num = 2

Proc SQL; 
Create Table Test as 
Select Name&Num.Full,
Year&Num.Last
From xx;
Quit;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 300 views
  • 1 like
  • 2 in conversation