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

Greetings SAS persons,

 

I have a prompt I am using in Enterprise Guide which requires the user to add a month in the input field in YYYYMM format, so for example '201811' for November 2018.

 

My code is creating a file which is exported as an excel file and I want to put into a folder, depending on the YYYYMM that is filled in.

 

So for example if the user puts 201811 in the prompt then the file needs to get written to:

 

"C:\My Directory\201811\MyExcelFiles_201811"

 

If the user puts in '201812' it will go into:

 

"C:\My Directory\201812\MyExcelFiles_201812"

 

and so on.

 

I think I can define this with a macro in the code, but I am not sure how can anyone help please?

 

Thanks

Andy

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

 

Here's some references that may help you. 

 

In general, just replace the value with the prompt with a & in front of it and period after. If you need to create a folder that doesn't already exist, you'll need to use DCREATE() to create the directory first with the file path and then use the path below to export it to. 

 

"C:\My Directory\&Prompt_Value.\MyExcelFiles_&prompt_value..pdf"

 

https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

 

https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

 


@AJChamberlain wrote:

Greetings SAS persons,

 

I have a prompt I am using in Enterprise Guide which requires the user to add a month in the input field in YYYYMM format, so for example '201811' for November 2018.

 

My code is creating a file which is exported as an excel file and I want to put into a folder, depending on the YYYYMM that is filled in.

 

So for example if the user puts 201811 in the prompt then the file needs to get written to:

 

"C:\My Directory\201811\MyExcelFiles_201811"

 

If the user puts in '201812' it will go into:

 

"C:\My Directory\201812\MyExcelFiles_201812"

 

and so on.

 

I think I can define this with a macro in the code, but I am not sure how can anyone help please?

 

Thanks

Andy


 

View solution in original post

4 REPLIES 4
Astounding
PROC Star

Do you have working code that does not use macro language?  For example, if you knew that the user was going to enter 201812, do you have a program that would export the file to the proper folder?

AJChamberlain
Obsidian | Level 7

Unfortunately not. I don't have to use a macro to solve this, if there's another way I'll take that!

 

Thanks

A

Reeza
Super User

 

Here's some references that may help you. 

 

In general, just replace the value with the prompt with a & in front of it and period after. If you need to create a folder that doesn't already exist, you'll need to use DCREATE() to create the directory first with the file path and then use the path below to export it to. 

 

"C:\My Directory\&Prompt_Value.\MyExcelFiles_&prompt_value..pdf"

 

https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

 

https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

 


@AJChamberlain wrote:

Greetings SAS persons,

 

I have a prompt I am using in Enterprise Guide which requires the user to add a month in the input field in YYYYMM format, so for example '201811' for November 2018.

 

My code is creating a file which is exported as an excel file and I want to put into a folder, depending on the YYYYMM that is filled in.

 

So for example if the user puts 201811 in the prompt then the file needs to get written to:

 

"C:\My Directory\201811\MyExcelFiles_201811"

 

If the user puts in '201812' it will go into:

 

"C:\My Directory\201812\MyExcelFiles_201812"

 

and so on.

 

I think I can define this with a macro in the code, but I am not sure how can anyone help please?

 

Thanks

Andy


 

AJChamberlain
Obsidian | Level 7

Thanks guys that's worked A

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1654 views
  • 0 likes
  • 3 in conversation