I am using SAS EG 8.3
I use File --> Import Data to import a few files to the SAS server.
Every new month, I have to Right Click the file and update the File Location.
Is there a way to parameterize the file location, so that all I just need to update from yymm=202304 to yymm = 202305 in a macro variable and the Import Data Wizard will pick up the new files?
Instead of the Import Wizard, use the Copy Files task (where you can use macro variables), and a subsequent code node to read the file after it has been copied to the SAS server.
Hi,
Supposing that the structure of the files being imported remains constant throughout the months and years, one way to do that is the following:
First, make sure that you selected the last option in the fourth step of the import object (you can "Modify task", select the option, and run to get the code):
That code will make reference to the file you're importing:
Now, copy all the code of the import to a new program, add a %LET statement at the top to create the macro variable that will establish the yearmonth to run (i called it YEARMONTH, name it as you like):
... and now you can replace with the new macro variable reference where needed (i don't know if the SAS table you're creating also contains the yearmonth, if it does, don't forget to replace there too), and run the program:
Two very important things here:
Hope this helps!
Best regards,
José Costa
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.