BookmarkSubscribeRSS Feed
sass_numero_uno
Fluorite | Level 6

Using a prompt, which takes a single integer numeric value, eg 4. How can I use this prompt to create a dynamic column name.

 

I use the prompt value to bring through certain columns, called something like "Names".

 

I would like to be able to name the columns something like "Names_Year_X".

 

Where X is the prompt value.

 

I have tried referring to the prompt value by using methods such as "Names_Year_&Prompt" and "Names_Year_&&Prompt&Prompt". 

 

However, none of the above methods work, nor do a number of others I've tried. Does anyone have any advice for house this might work? Preferably using the Query Builder, but if not using a program node for some code is a secondary back up option. 

4 REPLIES 4
tomrvincent
Rhodochrosite | Level 12
Have you tried adding a computed column with the name Names_Year_&Prompt?
sass_numero_uno
Fluorite | Level 6
Yes. I have attempted this, and it just appears as what a literally type, so in this instance, "Names_Year_&Prompt"
andreas_lds
Jade | Level 19

Please post the full code you used to create the dynamically named column.

tomrvincent
Rhodochrosite | Level 12
Take the code from your query builder and put it into a new program, then just change the single quotes to double quotes.

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1245 views
  • 0 likes
  • 3 in conversation