data _null_;
call symput('period',put(intnx('month',today(),-3),yymmn6.));
run;
May I know how to write the 'period' (201902) into a specific cell in Excel? Let say to cell E3.
Thanks.
Use SAS/IML to call R
Pass your data to R via SAS/IML
Pass R code to R via SAS/IML to do the writing to Excel for you
Use the openxlsx or XLConnect R packages to do the excel writing in R
(Not a great answer I know. the only SAS-program driven solution I've been able to find. The other solutions involve writing VBA code in Excel to pull data into excel versus pushing data to excel from a SAS program.)
See this paper for example code to get you started:
https://analytics.ncsu.edu/sesug/2017/SESUG2017_Paper-109_Final_PDF.pdf
This isn't elegant, but you could brute force it with something like:
%let value=201902;
data temp;
length a b c d e 8.;
output; *row 1;
output; *row 2;
e=&value;
output; *row 3;
run;
proc export data=temp
outfile="path\temp.xlsx"
dbms=xlsx
replace;
putnames=no; *no header row;
run;
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
CFC_SAS_Communities_400x225.jpg
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.