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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 906 views
  • 0 likes
  • 4 in conversation