BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I'm just start to study SAS, I try to creat a program @ my window system, I try to create 50 folders names:runs1,runs2.....runs50 under c:\saswork\runs\ ... like: "c:\saswork\runs\runs1,runs2--runs50"
I tried X "copy macro" ,but need keep to close CMD.exe, can you someone can help me to make the program for me ?
Thanks A Million in Advance.
Sasjunior
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Without seeing more of your code and Log error messages it is hard to comment. I have a few suggestions...
1) look up the correct syntax of the mkdir or md command on your operating system. I do not remember the MD command accepting a list of folders separated by commas
2) search the forum and/or support.sas.com for examples of external file and folder manipulation -- there have been previous forum postings on these topics.
3) look in the documentation (SAS Companion) for your operating system and/or consult with your SAS administrator to make sure that you correctly understand where you have permission to create folders -- for example if you are using SAS Enterprise Guide the X command may be disabled or you may not have write access to the location where you want to create folders.
4) you refer to an X command to "copy macro" -- do you want to execute a mkdir command or a copy command or invoke a .bat or .cmd file?? Your description of what you want to do is inconsistent with what you describe
5) look up the use of the options used in conjunction with the use of the X command - you should be able to find them in the same place you find the doc and examples of using the X command.

Cynthia
deleted_user
Not applicable
Hello,Cynthia thanks so much!
**************************************************************************************
data wjx; (defins Macros: runs1-runs50)
do i=1 to 50;
n='runs'||trim(left(i));
output;
end;
run;
options symbolgen;
data _null_;
set wjx;
call symput('runs'!!trim(left(i)),n);
run;
%put _user_;

%let folder=C:\saswork\;
%let subfolder=alex\;
*********************************************************************************************
x "md &folder&subfolder&runs1"; *create a folder;
********************************************************************************************
is have any way I can substitute "&runs1 " as automatic series Macros from runs1 to runs50 to keep create a series folders? can I use do loop or array... to do that?
I tried array, but itis very hard for me.
:date _null_;
array runs{50} runs1-runs50;
run;

%macro www(qqq);
x "md &folder&subfolder&qqq"
%mend;
%qqq(runs{50})

after modification, my idea is possable?
thanks again.
SASjunior
Cynthia_sas
SAS Super FREQ
Hi:

You may not need SAS macro processing at all. For example, if you read the documentation on the DCREATE function,
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a002986745.htm

you will discover that you can create a directory without using SAS Macro processing at all. Using the DCREATE approach, you could create your numbered folders using a simple DO loop, much like you show in your first DATA step program.

If you really, really want a SAS Macro approach, then you should read up a bit more on SAS Macro processing. This is a very good paper on the subject:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

The program below illlustrates how to create the folders ZZ1, ZZ2 and ZZ3 in the c:\temp\ directory.

cynthia
[pre]
data _null_;
do i = 1 to 3;
DirectoryName = catt('zz',put(i,1.0));
NewDirectory=dcreate(DirectoryName,'c:\temp\');
putlog newdirectory= directoryname=;
end;
run;
[pre]
art297
Opal | Level 21
I agree with Cynthia's suggested approach and, if you're really, really interested in learning macros, the paper she suggested.

However, since I wrote a macro (but didn't test it), I thought I'd share it before deleting it.

options noxwait nxsync;
%macro www(folder,subfolder,fname,numruns);
data _null_;
%do i=1 %to &numruns.;
call system ("md &folder.&subfolder.&fname.&i.");
%end;
run;
%mend;

%www(C:\saswork\,alex\,runs,50)

Art
deleted_user
Not applicable
Cynthia & art297
thanks a million again for helping a small guy.
your both codes work great. I think I need to spend a few years to catch up with your tail.
but I will study hard to do that.

Nice weekend!
SASjunior

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 725 views
  • 0 likes
  • 3 in conversation