If you want to do this with macros:
data _null_; set work.users; call symput('filename', cats('/home/me/', user_id, '.jpg')); run; data _null_; set work.users; file "&filename." noprint; put imagedata; run;
However, this assumes that there is only one observation in work.users , which I assume is incorrect. If you want to display a file for each observation, collapse it into a macro:
%macro writefile(n); %do i = 1 %to &n; data _null_; i = &i; set users point=i; call symput('filename', cats('c:\temp\', user_id, '.txt')); stop; run; data _null_; i = &i; set users point=i; file "&filename." noprint; put imagedata; stop; run; %end; %mend;
Here, the argument & n is the number of observations in your dataset. You can get it programmatically, but for current purposes, it's easier to pass it manually to a macro.
source share