BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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
Onyx | Level 15

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
Onyx | Level 15

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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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