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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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