BookmarkSubscribeRSS Feed
2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

This post easily earns the price for the tersest question!

 

Using a libname statement with the xlsx engine allows you to push data into an existing file.

 

%* Create sample excel file;
proc export data=SASHELP.CLASS(obs=2) dbms=xlsx outfile="%sysfunc(pathname(WORK))\class.xlsx" replace;run;

%* Print contents;
libname XL xlsx "%sysfunc(pathname(WORK))\class.xlsx";
proc print data=XL.CLASS; run;

%* Update and print contents;
data XL.CLASS; set SASHELP.CLASS(obs=3); run;
proc print data=XL.CLASS; run;

Obs Name Sex Age Height Weight
1 Alfred M 14 69 112.5
2 Alice F 13 56.5 84

 



Obs Name Sex Age Height Weight
1 Alfred M 14 69 112.5
2 Alice F 13 56.5 84
3 Barbara F 13 65.3 98

 

SASKiwi
PROC Star

One approach that works well is to use the SAS Add-in to MS Office. You set a data sheet that is simply a copy of a SAS dataset. When you want to update it you just use the SAS tab on the Excel menu and do a Data Refresh.

 

The next step is you run an Excel macro (I'm assuming competence in this area, something I lack) which reads the data sheet and then populates your pre-formatted sheet exactly how you want it.

 

The advantage of this method is it is simple, the disadvantage is it requires manual steps.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 881 views
  • 1 like
  • 3 in conversation