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
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
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?
Unfortunately not. I don't have to use a macro to solve this, if there's another way I'll take that!
Thanks
A
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
Thanks guys that's worked A
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!
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.