- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%macro export_data; %do i =1 %to 10; proc export data=work.out_D&i. outfile= "C:\Users\export from sas\testD&i..csv" dbms=csv replace; PUTNAMES=YES; run; %end; %mend export_data;
Hello there - I am trying to export datasets from SAS to .csv files (a separate .csv file for each dataset) but I am not getting the results and need help to figure out the errors.
Regards,
Sara
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
All your log is showing is that you defined the macro.
If you want to macro to generate the code to export a file you need to call the macro.
Add these two lines after the %MEND line.
options mprint;
%export_data;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There isn't anything wrong with your program syntax. The most likely cause is you are trying to write the CSVs to your local PC C drive when your SAS session is running on a remote SAS server. This server has no way of identifying your PC C drive. It would help if you posted your SAS log, including the errors, so we can confirm if this is what is happening or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The problem is that it is not giving any errors or warnings in the log.
My SAS installed locally and I am not using the remote server. I think the way I call multiple files in the outfile, is not correct and causing the problem
13989 %macro export_data; 13990 %do i =1 %to 10; 13991 proc export data=work.out_D&i. 13992 outfile= "C:\Users\testD&i..csv" 13993 dbms=csv replace; 13994 PUTNAMES=YES; 13995 run; 13996 %end; 13997 %mend export_data;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
All your log is showing is that you defined the macro.
If you want to macro to generate the code to export a file you need to call the macro.
Add these two lines after the %MEND line.
options mprint;
%export_data;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content