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;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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