DATA Step, Macro, Functions and more

Export Just a Variable to Excel

Reply
Frequent Contributor
Frequent Contributor
Posts: 83

Export Just a Variable to Excel

Hi all,

 

I've been trying to solve this problem on and off for a number of days without much luck. Appreciate any thoughts on it.

 

I create this variable:


%let today = today(); 
data _null_;
call symput ('Stamp',"Report created: "||put(today(),mmddyy10.));
run; 
%put &Stamp;

It gives me the following: Report created: mm/dd/yyyy

 

All I want to do is take this variable and export it to a specific cell in excel. Seems easy, maybe it is, but I haven't been able to figure out how to do it without creating a table in SAS first. 

 

I can't use DDE because the code will ultimately run from a server that does not have excel installed. I can do it locally but ultimately that's not gonna work.

 

Code for the curious:

options noxwait noxsync xmin;
%sysexec "&Directory\&tprogram..xlsb";

data _null_;
rc = sleep(15);
run;


filename Workbook DDE 'Excel|Sheet1!R1C1';
data _null_;
file Workbook;
Stamp = "&Stamp";
put Stamp;
run;

 

I've resorted to creating a table and appending it.:

data Stamp; 
Time_Stamp = "&Stamp"; 
run;

Libname WrkBk EXCEL "&directory\&program..xlsb" Scan_Text = No;

PROC DATASETS 
LIB = WrkBk;
DELETE Stamp;
RUN;
QUIT;

PROC APPEND 
BASE = WrkBk.Stamp
DATA = Stamp;
RUN;

Libname WrkBk CLEAR;

Is there a way to just export the variable without having to go through the process of creating a table for it while also not using DDE? Maybe ODS? Appreciate any thoughts.

Super User
Posts: 17,750

Re: Export Just a Variable to Excel

Not if you want it in a specific cell. 

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 155 views
  • 0 likes
  • 2 in conversation