I don't know if this is even possible, but I'm just going to throw this question out there.
I was wondering if SAS has the ability to create folders? For example, suppose I automatically run code every week that generates a host of output files. Suppose I output them in C:\SAS\Reports, but I want to have a new subfolder with the date each time the reports are generated so that this week they are output to C:\SAS\Reports\2015-02-20 and next week they are output to C:\SAS\Reports\2015-02-27, and so on. This way, I don't have to manually create a new folder each time and move all the files from one place to another.
Is this possible?
DCREATE function.
DCREATE function.
Or use call system (in a data step) or the X statement (anywhere in SAS code).
At the risk of being obnoxious, me still think DCREAT is the better option. Let SAS to worry about OS. You went a great deal of using Macro, you can host your OS independent directory into Macro variable, so it even makes more sense for you to NOT use 'MD'. What if later on your system is being migrated to Linux (or any other OS that SAS is running on)? switch it to 'mkdir'?
Just my2cents,
Haikuo
Since one already has to consider the underlying OS's naming syntax when using any of the methods, I don't see the possible migration as a major argument. Personally, I would use the filename pipe and data _null_ step method to get a comprehensive log in case something went wrong.
In a case where the "create a directory" function is done via macro, only one macro needs to be adapted to a new platform, but all calls need to be checked for syntax anyway (a "C:\" in a UNIX path name may have interesting consequences)
I would agree with you Hai.kuo, for the reasons you have given, and also that piping commands out to system sometimes is blocked by admin, and if it doesn't work - i.e. macro does not work correctly, you do run the risk of removing things unintentionally, or creating loads of unwanted folders etc. temporary areas.
At the risk of appearing vain, here's a sample I submitted a few years ago - https://communities.sas.com/thread/71369
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.