|
Excel Tagsets is well suited to this task; here's an example macro that I
use:
%macro do_calls_report;
ods listing close;
ods tagsets.excelxp
file='C:\Work_Activities\injections_study_patients\results_report2.xml'
style=analysis
options(absolute_column_width='10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10'
sheet_label=' ');
proc sql;
create table bylist as
select distinct isv_study_nbr, substr(isv_study_nbr,5,2) as year
from isv_injection_study_visits;
quit;
run;
proc sort data=bylist;
by year isv_study_nbr;
run;
data bylist;
set bylist;
obsnum + 1;
run;
proc sql noprint;
select count(*) into :model_count
from bylist;
quit;
%put &model_count;
%Do I = 1 %To &model_count;
proc sql noprint;
select isv_study_nbr into :sheetname
from bylist
where obsnum =&i;
quit;
data results;
set isv_injection_study_visits;
if isv_study_nbr= "&sheetname";
run;
ods tagsets.excelxp options(sheet_name="&sheetname");
proc report data=results nowindows
style(report)=[rules=all cellspacing=0 bordercolor=lightgreen]
style(header)=[background=lightskyblue foreground=black]
style(column)=[background=white foreground=black vjust=top];
column
isv_study_nbr
isv_visit_location
isv_visitdate
isv_age
isv_fa
isv_od_va
isv_od_va_logmar
isv_od_first_logmar
isv_od_logmar_diff
calc_od_logmar_diff_formatted
isv_od_treatment
isv_od_log_er_nomaint
isv_od_log_er_maint
isv_od_log_dr
isv_od_log_nr
isv_od_log_nc
isv_od_ph_mr
isv_od_fa_kg_comments
isv_od_oct_cmt
isv_od_oct_kg
isv_od_rott
isv_od_stage_comments
isv_od_er_nomaint
isv_od_er_maint
isv_od_dr
isv_od_nr
isv_od_nc
isv_os_va
isv_os_va_logmar
isv_os_first_logmar
isv_os_logmar_diff
calc_os_logmar_diff_formatted
isv_os_treatment
isv_os_logmar_er_nomaint
isv_os_logmar_er_maint
isv_os_logmar_dr
isv_os_logmar_nr
isv_os_logmar_nc
isv_os_ph_mr
isv_os_fa_kg_comments
isv_os_oct_cmt
isv_os_oct_kg_comments
isv_os_rott
isv_os_stage_comments
isv_os_er_nomaint
isv_os_er_maint
isv_os_dr
isv_os_nr
isv_os_nc
isv_medical_information ;
define isv_study_nbr/display 'Study Nbr';
define isv_visit_location/display 'Visit Location';
define isv_visitdate/display 'Date of Visit';
define isv_age/display 'Age';
define isv_fa/display 'FA';
define isv_od_va/display 'VA OD';
define isv_od_va_logmar/display 'VA OD LogMar';
define isv_od_first_logmar/display 'First OD LogMar';
define isv_od_logmar_diff/display noprint 'Logmar OD Diff';
define calc_od_logmar_diff_formatted/computed 'Logmar OD Diff';
define isv_od_treatment/display 'Treatment OD';
define isv_od_log_er_nomaint/display 'LogMar Early Responder NoMaint OD';
define isv_od_log_er_maint/display 'LogMar Early Responder Maint OD';
define isv_od_log_dr/display 'LogMar Delayed Responder OD';
define isv_od_log_nr/display 'LogMar Non-Responder OD';
define isv_od_log_nc/display 'LogMar Not Considered OD';
define isv_od_ph_mr/display 'PH/MR OD';
define isv_od_fa_kg_comments/display 'FA OD KG Comments';
define isv_od_oct_cmt/display 'OCT CMT OD';
define isv_od_oct_kg/display 'OCT OD KG Comments' ;
define isv_od_rott/display 'ROTTERDAM STAGE 0 4 OD';
define isv_od_stage_comments/display 'OD Stage Comments' ;
define isv_od_er_nomaint/display 'Early Responder No Maint OD';
define isv_od_er_maint/display 'Early Responder Maint OD';
define isv_od_dr/display 'Delayed Responder OD';
define isv_od_nr/display 'Nonresponder OD';
define isv_od_nc/display 'Not Considered OD';
define isv_os_va/display 'VA OS';
define isv_os_va_logmar/display 'VA OS LogMar';
define isv_os_first_logmar/display 'First OS LogMar';
define isv_os_logmar_diff/display noprint;
define calc_os_logmar_diff_formatted/computed 'Logmar OS Diff';
define isv_os_treatment/display 'Treatment OS';
define isv_os_logmar_er_nomaint/display 'LogMar Early Responder NoMaint OS';
define isv_os_logmar_er_maint/display 'LogMar Early Responder Maint OS';
define isv_os_logmar_dr/display 'LogMar Delayed Responder OS';
define isv_os_logmar_nr/display 'LogMar Non-Responder OS';
define isv_os_logmar_nc/display 'LogMar Not Considered OS';
define isv_os_ph_mr/display 'PH/MR OS';
define isv_os_fa_kg_comments/display 'FA OS KG Comments' ;
define isv_os_oct_cmt/display 'OCT CMT OS';
define isv_os_oct_kg_comments/display 'OCT OS KG Comments' ;
define isv_os_rott/display 'ROTTERDAM STAGE 0 4 OS';
define isv_os_stage_comments/display 'OS Stage Comments';
define isv_os_er_nomaint/display 'Early Responder No Maint OS';
define isv_os_er_maint/display 'Early Responder Maint OS';
define isv_os_dr/display 'Delayed Responder OS';
define isv_os_nr/display 'Non-Responder OS';
define isv_os_nc/display 'Not Considered OS';
define isv_medical_information/display 'UPDATED MEDICAL INFORMATION';
compute calc_od_logmar_diff_formatted;
if isv_od_logmar_diff = . or
(isv_od_logmar_diff >= -.1 and isv_od_logmar_diff <=.2) then
calc_od_logmar_diff_formatted= isv_od_logmar_diff;
else if isv_od_logmar_diff > .2 then
do;
calc_od_logmar_diff_formatted= isv_od_logmar_diff;
call define(_col_,'style',
'style=[foreground=black
background=green
font_weight=bold]');
end;
else if isv_od_logmar_diff < -.1 then
do;
calc_od_logmar_diff_formatted= isv_od_logmar_diff;
call define(_col_,'style',
'style=[foreground=black
background=red
font_weight=bold]');
end;
endcomp;
compute calc_os_logmar_diff_formatted;
if isv_os_logmar_diff = . or
(isv_os_logmar_diff >= -.1 and isv_os_logmar_diff <=.2) then
calc_os_logmar_diff_formatted= isv_os_logmar_diff;
else if isv_os_logmar_diff > .2 then
do;
calc_os_logmar_diff_formatted= isv_os_logmar_diff;
call define(_col_,'style',
'style=[foreground=black
background=green
font_weight=bold]');
end;
else if isv_os_logmar_diff < -.1 then
do;
calc_os_logmar_diff_formatted= isv_os_logmar_diff;
call define(_col_,'style',
'style=[foreground=black
background=red
font_weight=bold]');
end;
endcomp;
run;
%End ;
ods tagsets.excelxp close;
ods listing;
%mend;
%do_calls_report;
-Mary
----- Original Message -----
From: Adriano Rodrigues
To: SAS-L@LISTSERV.UGA.EDU
Sent: Wednesday, December 10, 2008 3:43 PM
Subject: exporting to excel multiple sheets
Hi all,
I know how to export all my data to Excel, but I want export in the same
file, one plan with all my customers plus my customers by state, with one
state in each plan in same file. Can someone recommend me one good paper so
I can read and learn?
Thanks in advance,
Adriano
|