LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 6 Feb 2010 09:59:56 -0800
Reply-To:     SAS_learner <proccontents@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS_learner <proccontents@GMAIL.COM>
Subject:      Re: Getting variables into Proc Report dynamically
Comments: To: Jim Groeneveld <jim.1stat@yahoo.com>
In-Reply-To:  <201002061344.o16CanUN027215@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Hello Jim, Thanks for the macro I tried to use that was not sure I am doing it right or wrong, The reason I asked data _null_ in his version of clinical reporting macro at this part got the label with in the dataset

at this place I wanted to same thing thing but instead of traditional proc Report and supplying my list of variables in the column statement and then supplying the labels and other things using define statement . I particularly liked part

define col_: / display style(column)=[just=center];

where all the variables starting with Col_: would in the column statement and also in define statement. I want to do something similar but list of variables coming from a macro (because I can increase or decrease the list of variables ) then display them with the change of variables coming from either dataset or macro list. Is it possible to something like that ?? ( with the Options in displaying in Center or Left or Right)

ods rtf file='demogTable01.rtf'; ods listing close; title 'Table 14-1.2.3b'; title2 'Summary of Age, Height and Weight'; proc report list nowd data=display headline split='~'; column vorder _name_ statgrp col_:; define vorder / order noprint; define _name_ / order 'Variable'; define statgrp / order order=internal 'Statistic' width=10 style=[just=left];

define col_: / display style(column)=[just=center]; * conditional blank lines; compute before _name_; n + 1; if n gt 1 then l=1; else l=0; text = ' '; line text $varying1. l; endcomp; run; ods rtf close; ods listing; title;

---------- Forwarded message ---------- From: Data _null_; <iebupdte@gmail.com> Date: Wed, Sep 30, 2009 at 1:01 PM Subject: Clinical Trials Reporting. To: SAS-L@listserv.uga.edu

* Goals: * 1) Use standard SAS meta data objects, FORMATS LABELS. * 2) Dynamic, with regards to input * a) levels of column variable * b) column variable type * c) number of analysis variables. * d) just need the names * 3) No references to the values of a variable, * In order words we don't need to know any value of any variable * 4) Reasonable looking CT table. * 5) Code can be reused, more specifically the technique * 6) Combine into one table cell MEAN(SD) and MIN, MAX. ;

* Assumptions: * 1) Formatted value of column variable will provide column labels * 2) Internal value of column variable determines the column order * 3) No variables from input data begin with "COL" ; proc format; value $sex 'F'='Female' 'M'='Male'; value sex 1 ='Female' 2 ='Male'; run; data work.ADSL; set sashelp.class; sexN = index('MF',sex); format age F3.0 height 6.1 weight Comma7.2 sex $sex. sexN sex.; attrib sex: label='Treatment' ; *rename sexN=sex sex=sexC; /*un-comment to test SEX numeric*/ run; proc contents varnum; proc print; format _all_; run;

* Specify the analysis variables and column variable; %let trt = sex; %let vars = age--weight;

* Expand the (VARS) variable list, and make a FORMAT statement argument for MEAN, STD and MEDIAN; * To display those statistics with one more decimal place than the format assiociated with the variable; proc transpose data=work.adsl(obs=0) out=vars; var &vars; run; data work.vars(index=(_name_)); set work.vars end=eof; vorder = _n_; vformatN = vformatNX(_name_); vformatD = vformatdX(_name_); length fmt1 $16.; fmt1 = cats(vformatN,12,'.',vformatD+ 1); return; set work.adsl(keep=&vars); drop &vars; run; proc sql noprint; select _name_, catx(' ',_name_, fmt1) into :vars separated by ' ', :fmt1 separated by ' ' from work.vars; quit; run; %put NOTE: VARS=&vars; %put NOTE: FMT1=&fmt1;

** Compute summary statistics; proc summary data=work.ADSL nway completetypes; class sex / preloadfmt; var &vars; output out=work.stats(drop=_type_); output out=work.median(drop=_type_) median=; run; proc format; invalue statord(upcase just) 'N'=1 'MEAN'=2 'STD'=4 'MEDIAN'=4 'MIN'=5 'MAX'=5; invalue statgrp(upcase just) 'N'=1 'MEAN','STD'=2 'MEDIAN'=3 'MIN','MAX'=4; value statgrp 1='N' 2='Mean (SD)' 3='Median' 4='Min, Max'; run;

data stats; set stats median(in=in2); by sex; if in2 then _STAT_ = 'MEDIAN'; order = input(_stat_,statord.); retain dummy '12345678'; run;

proc transpose data=stats out=stat1; by sex _freq_ _stat_ order notsorted; where _stat_ eq 'N'; var &vars dummy; format &vars 12.; run; proc transpose data=stats out=stat2; by sex _freq_ _stat_ order notsorted; where _stat_ in('MIN','MAX'); var &vars dummy; run; proc transpose data=stats out=stat3; by sex _freq_ _stat_ order notsorted; where _stat_ in('MEAN','STD','MEDIAN'); var &vars dummy; format &fmt1; run; data work.stats; set work.stat1 work.stat2 work.stat3; where upcase(_name_) ne 'DUMMY'; attrib statgrp length=8 format=statgrp. label='Statistic'; statgrp = input(_stat_,statgrp.); col1 = left(col1); format statgrp statgrp.; run; proc sort; by _name_ sex _freq_ statgrp order _stat_; run; proc transpose data=work.stats out=work.stats; by _name_ sex _freq_ statgrp; var col1; run; data stats; set stats; length cell $32; select(statgrp); when(2) cell = catx(' ',col1,cats('(',col2,')')); when(4) cell = catx(', ',col1,col2); otherwise cell = col1; end; * Create column header for the "treatment" columns; length label $64; label = catx('~',vvalue(sex),cats('(N=',_freq_,')')); * Variable order; set vars(keep=_name_ vorder) key=_name_/unique; drop col:; run; proc sort; by vorder _name_ statgrp sex; run; proc transpose data=stats out=display prefix=col_; by vorder _name_ statgrp; var cell; id sex; format sex; idlabel label; run; proc contents varnum; run; proc print; format _all_; run;

ods rtf file='demogTable01.rtf'; ods listing close; title 'Table 14-1.2.3b'; title2 'Summary of Age, Height and Weight'; proc report list nowd data=display headline split='~'; column vorder _name_ statgrp col_:; define vorder / order noprint; define _name_ / order 'Variable'; define statgrp / order order=internal 'Statistic' width=10 style=[just=left];

define col_: / display style(column)=[just=center]; * conditional blank lines; compute before _name_; n + 1; if n gt 1 then l=1; else l=0; text = ' '; line text $varying1. l; endcomp; run; ods rtf close; ods listing; title;


Back to: Top of message | Previous page | Main SAS-L page