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-wordmark-2025-midnight.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. Sign up by March 14 for just $795.


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