BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jhusoc
Obsidian | Level 7
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
Ksharp
Super User
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;

View solution in original post

4 REPLIES 4
jhusoc
Obsidian | Level 7

the format is messed up!

jhusoc_0-1619645202372.png

 

Reeza
Super User
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.
Ksharp
Super User
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;
jhusoc
Obsidian | Level 7
Thank you so much!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 932 views
  • 1 like
  • 3 in conversation