BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

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.

 

 

3 REPLIES 3
Reeza
Super User
You can't. You can export a data set but that will add the column header. I don't believe there's a way to have a single value put to a cell besides other alternatives that are well documented on here. DDE was the old method which still technically works but I would never recommend building anything relying on that technology.
DWilson
Pyrite | Level 9

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

 

 

noling
SAS Employee

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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 3 replies
  • 1933 views
  • 0 likes
  • 4 in conversation