🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-28-2021 05:18 PM
(975 views)
Hi all, I run SAS script every day. I get a small table like this: Obs County total_cases new_case 1 A 21 0 2 B 2 2 3 C 1 0 I want it to export to excel. On the second day, I run SAS, and I get another output: Obs County total_cases new_case 1 A 22 1 2 B 2 0 3 C 6 5 Can I export the results to the excel I create on the first day? The excel like this, Obs County total_cases new_case 1 A 21 0 2 B 2 2 3 C 1 0 1 A 22 1 2 B 2 0 3 C 6 5 Thank you all! JH
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
libname x excel 'c:\temp\temp.xlsx' SCAN_TEXT=NO;
/*first run*/
data x.sheet1;
set sashelp.class;
run;
/*second run*/
proc sql;
insert into x.sheet1
select * from sashelp.class;
quit;
/*third run*/
proc sql;
insert into x.sheet1
select * from sashelp.class;
quit;
libname x clear;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
the format is messed up!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can for a CSV but not as easily for an Excel file. Another workaround is to have a SAS dataset that maintains those old values and each day you append the new results to that table and then export it all out again to the new file or replace the full table in the old file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
libname x excel 'c:\temp\temp.xlsx' SCAN_TEXT=NO;
/*first run*/
data x.sheet1;
set sashelp.class;
run;
/*second run*/
proc sql;
insert into x.sheet1
select * from sashelp.class;
quit;
/*third run*/
proc sql;
insert into x.sheet1
select * from sashelp.class;
quit;
libname x clear;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much!