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