02-18-2015 04:51 PM
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?
02-19-2015 01:35 AM
Or use call system (in a data step) or the X statement (anywhere in SAS code).
02-19-2015 03:43 AM
02-19-2015 09:03 AM
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'?
02-19-2015 09:32 AM
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)
02-19-2015 09:32 AM
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.
Need further help from the community? Please ask a new question.