Skip to Main Content

long1.htm


SAS Code Fragments

Creating a wide table from a long data
set using Proc Tabulate

Inputting the dataset.

data output;
 input Parameter $ Estimate StdErr group;
cards;
Intercept          3.7550      0.9902      1
z1                -0.1456      0.4602      1
z2                -0.6483      0.3552      1
z3                -1.6350      0.3985      1
age               -0.0197      0.0142      1
Scale              1.0000      0.0000      1
Weibull            1.0000      0.0000      1
Intercept          3.5288      0.9041      2
z1                -0.1477      0.4076      2
z2                -0.5866      0.3199      2
z3                -1.5441      0.3633      2
age               -0.0175      0.0128      2
Scale              0.8848      0.1084      2
Weibull            1.1301      0.1384      2
Intercept          3.1022      0.9527      3
z1                -0.1257      0.4152      3
z2                -0.8057      0.3539      3
z3                -1.7661      0.4257      3
age               -0.0151      0.0138      3
Scale              0.7152      0.0860      3
Intercept          3.3832      0.9356      4
z1                -0.1989      0.4423      4
z2                -0.8995      0.3634      4
z3                -1.8574      0.4427      4
age               -0.0185      0.0137      4
Scale              1.2638      0.1346      4
Intercept          3.4535      0.9437      5
z1                -0.1584      0.4308      5
z2                -0.7583      0.3938      5
z3                -1.7293      0.4488      5
age               -0.0178      0.0135      5
Scale              1.1039      0.2570      5
Shape              0.4581      0.5837      5
;
run;
proc format;
  value g 1='Exp' 2='Weibull' 3='Log Logistic' 4='Log Normal' 5='Gamma';
run;

We
want the columns for estimate and stderr to be next to each other within each
group.


proc tabulate data=output;
  class group parameter;
  var estimate stderr;
  table parameter='', sum=' '*group=' '*(estimate='Est' stderr='SE')*f=7.5 / RTS=15;
  format group g.;
run;








———————————————————————————————–
| | Exp | Weibull | Log Logistic | Log Normal | Gamma |
| |—————+—————+—————+—————+—————|
| | Est | SE | Est | SE | Est | SE | Est | SE | Est | SE |
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|Intercep |3.75500|0.99020|3.52880|0.90410|3.10220|0.95270|3.38320|0.93560|3.45350|0.94370|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|Scale |1.00000|0.00000|0.88480|0.10840|0.71520|0.08600|1.26380|0.13460|1.10390|0.25700|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|Shape | .| .| .| .| .| .| .| .|0.45810|0.58370|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|Weibull |1.00000|0.00000|1.13010|0.13840| .| .| .| .| .| .|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|age |-.01970|0.01420|-.01750|0.01280|-.01510|0.01380|-.01850|0.01370|-.01780|0.01350|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|z1 |-.14560|0.46020|-.14770|0.40760|-.12570|0.41520|-.19890|0.44230|-.15840|0.43080|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|z2 |-.64830|0.35520|-.58660|0.31990|-.80570|0.35390|-.89950|0.36340|-.75830|0.39380|
|————-+——-+——-+——-+——-+——-+——-+——-+——-+——-+——-|
|z3 |-1.6350|0.39850|-1.5441|0.36330|-1.7661|0.42570|-1.8574|0.44270|-1.7293|0.44880|
———————————————————————————————–