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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.