BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I want to create a folder(Directory) for each car maker (SAShelp.cars data set)

Name of the field  in (SAShelp.cars data set is  "Make"

What is the way to do it please?

 

 

 

7 REPLIES 7
andreas_lds
Jade | Level 19
Sort by Make, use "by make" in a data step. On first.Make create the directory using function dcreate.
Ronein
Meteorite | Level 14

I know to create one NewDirectory.

data _null_;
NewDirectory=dcreate("RRRT1","path");
run;

However, I dont know how to do it for multiple.

Should I use macro?

Can you show the code please?

Ronein
Meteorite | Level 14

Thank you.

I have tried but still I got only one folder called "make"  instead of 38 folders...

 PROC SQL;
	create table bbbb  as
	select distinct Make as Make 	   
	from sashelp.cars 
	order by Make
;
QUIT;

data _null_;
NewDirectory=dcreate("sashelp.cars","/path/");
run;

Data cccc;
set bbbb;
by Make;
NewDirectory=dcreate("Make","/path/sashelp.cars");
Run;
andreas_lds
Jade | Level 19
Remove the quotes from "Make l" if you want the value in Make as directory name.
andreas_lds
Jade | Level 19
Untested code - without group-processing:
Proc sort data=sashelp.cars out=work.make(keep=Make) nodupkey;
By make;
Run;
Data _null_;
Set Make;

Length NewDirectory $ 200;
Retain NewDirectory;

If _n_ =1 then do;
NewDirectory=dcreate("sashelp.cars","/path/");
End;

MakeDir = dcreate(Make, NewDirectory);
Run;
PeterClemmensen
Tourmaline | Level 20
proc sort data=sashelp.cars out=cars;
   by Make;
run;

data _null_;
   set cars;
   by Make;
   if first.Make then do;
      NewDirectory=dcreate(Make,"c:\");
   end;
run;

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1257 views
  • 0 likes
  • 4 in conversation