FILENAME new "C:\new\abc.txt";
data _null_;
file new dsd dlm = ';';
set atmdata;
format txt $18.;
by client_no atm_id;
if _N_ = 1 then
put 'name;'
'ATM ;'
'transacation_number;'
;
put client_no
atm_id
Transacation
;
run;
filename NEW;
I am writing above code to write data set atmdata to a file new
Now I want same data set to be written into different directory
FILENAME new1 "D:\new1\abc.txt";
I do not want to write data statement again to write into different directory
Can i write two filename staemnet with one data step ?
How can i acheive that
I think you need another data step. Add this after the step you have:
FILENAME new1 "C:\temp\abc1.txt";
data _null_;
rc = fcopy('new','new1');
run;
You could probably do it with a loop but FCOPY is probably more efficient, which would copy the written file, which is faster than writing to two places.
data _null_;
set have end=eof;
...rest of code;
if eof then do;
rc = fcopy(....);
end;
run;
@shubham1 wrote:
FILENAME new "C:\new\abc.txt"; data _null_; file new dsd dlm = ';'; set atmdata; format txt $18.; by client_no atm_id; if _N_ = 1 then put 'name;' 'ATM ;' 'transacation_number;' ; put client_no atm_id Transacation ; run; filename NEW;
I am writing above code to write data set atmdata to a file new
Now I want same data set to be written into different directory
FILENAME new1 "D:\new1\abc.txt";
I do not want to write data statement again to write into different directoryCan i write two filename staemnet with one data step ?
How can i acheive that
Can you give me a code as I am not able to get it how it should write
I think you need another data step. Add this after the step you have:
FILENAME new1 "C:\temp\abc1.txt";
data _null_;
rc = fcopy('new','new1');
run;
Something like this should work:
data _null_;
set atmdata;
format txt $18.;
by client_no atm_id;
file new dsd dlm = ';';
link WriteFile;
file new2 dsd dlm = ';';
link WriteFile;
WriteFile:
if _N_ = 1 then
put 'name;'
'ATM ;'
'transacation_number;'
;
put client_no
atm_id
Transacation
;
return;
run;
Thanks It worked now
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!
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.