BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Can anyone teach me how to loop the records in a dataset and
put it on a macro variable and create file?

I have attached a sample but it is not working.

data _null_;
do until(eof);
set sample end=eof;
file "d:\data\"&file".html";
end;
run;
2 REPLIES 2
GertNissen
Barite | Level 11
do you want to write the names of the variables to a file ?

%let file = variables;
data _null_;
set sashelp.vcolumn(where=(libname='SASHELP' and memname='CLASS'));
file "d:\&file..html" dsd;
put name @;
run;
GertNissen
Barite | Level 11
or do you want to create a new file name from the content of your data ?

data _null_;
set sashelp.class;
filename= cats('d:\',name,'.htm');
file dummy filevar=filename dsd;
put age;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1196 views
  • 0 likes
  • 2 in conversation