I have a Proc Freq that produces a column of 3 numbers (Column name 'N', row 1 name is 'All', row 2 name is 'Female', row 3 name is 'Male'. Column N contains headcounts. The dataset name is B1A.
I want to write these three numbers to an external excel file called 'Final_Table_Test.xlsx; tab name is .Table'.
The Excel file is: filename DDE "excel|C:\...\2020-2021 TABLE\[FINAL_Table_TEST.xlsx]Table!R6C3:R8C3".
At one time (years ago), I I wrote something like this that actually did this.
DATA _NULL_;
set SANDBOX.B1A;
INFILE 'B1A';
input N;
FILE FINAL_Table_TEST;
PUT CELL1 CELL2 CELL3;
RUN;
However, no manipulation I have tried works. I get the following error:
ERROR: Physical file does not exist, C:\WINDOWS\system32\B1A.
ERROR: Insufficient authorization to access C:\WINDOWS\system32\FINAL_TABLE_TEST.
Any ides?
proc summary data=sashelp.heart ;
class sex;
output out=have ;
run;
data _null_;
set have;
if missing(sex) then call symputx('all',_freq_);
else call symputx(sex,_freq_);
run;
libname x excel 'c:\temp\FINAL_Table_TEST.xlsx' scan_text=no getnames=no;
proc sql;
update x.'sheet1$'n
set f2="&all"
where lowcase(f1)='all students'
;
update x.'sheet1$'n
set f2="&female"
where lowcase(f1)='females'
;
update x.'sheet1$'n
set f2="&male"
where lowcase(f1)='males'
;
quit;
libname x clear;
proc summary data=sashelp.heart ;
class sex;
output out=have ;
run;
data _null_;
set have;
if missing(sex) then call symputx('all',_freq_);
else call symputx(sex,_freq_);
run;
libname x excel 'c:\temp\FINAL_Table_TEST.xlsx' scan_text=no getnames=no;
proc sql;
update x.'sheet1$'n
set f2="&all"
where lowcase(f1)='all students'
;
update x.'sheet1$'n
set f2="&female"
where lowcase(f1)='females'
;
update x.'sheet1$'n
set f2="&male"
where lowcase(f1)='males'
;
quit;
libname x clear;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.