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

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