Tuesday, November 19, 2013

Convert CHAR to NUM in PROC SQL

Use TO_NUMBER function in PROC SQL.

proc sql;
   connect to oracle (user=xxx orapw=yyy path="@zzz");
     create table temp as
       select * from connection to oracle
              (select aa, to_number(bb) as bb, to_number(cc) as cc
                          from xxx.dddd)
       where bb ne . or cc ne .
       order by aa;
   disconnect from oracle;
quit;
run;

Wednesday, July 10, 2013

Power Calculation

Example of finding power of a balanced one way ANOVA:
proc power;
        onewayanova test = overall
        groupmeans = 59 | 66 | 42
        std = 5 8 10 12
        npergroup = 3 4 5 6 7 8 9 10
        power = . ;
        plot ;
run;

Contrast power:
proc power;
        onewayanova test = contrast
        contrast = (1 -1 0 0 0 0) (0 1 0 0 -1 0) (0 0 1 -1 0 0)
        groupmeans = (5 4 6 11 12 9)
        std = 4
        npergroup = 5
        power = .
        ;
run;

Example of finding n of an unbalanced one way ANOVA:
proc power;
        onewayanova test = overall
        groupmeans = 3 | 7 | 8
        stddev = 4
        groupweights = (1 2 2)
        ntotal = .
        power = 0.8
        ;
run;

Example of finding power of a chi-squared test:
proc power;
        twosamplefreq test = pchi
        groupproportions = (.6 .4) (.7 .3) (.55 .45) (.49 .51)
        nullproportiondiff = 0
        npergroup =25 50 75 100 200
        power = . ;
        plot;
run;

Click Here

Example of finding power for a survival analysis:
proc power;
        twosamplesurvival test = logrank
        gexphs = 0.3567 | 0.5978 0.6931
        grouplossexphazards = (0.3567 0.3567)
        accrualtime = 1
        followuptime = 1
        groupweights = (1 2)
        power = .
        ntotal = 225 ;
run;

Click Here

Example of finding power of a two-sample t test:
proc power;
        twosamplemeans test=diff
        meandiff = 5 6
        stddev = 12 18
        alpha = 0.05 0.1
        ntotal = 100 200
        power = . ;
        plot ;
run;

Click Here