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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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