BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tmcrouse
Calcite | Level 5

I asked for help with a proc transpose and was told to create sep datasets and I did this but my proc transpose items are still not working the way they should with my merged datasets.

strataofc_cathsofc_pcisofc_sechoofc_tteofc_perfsop_cathsop_mpisop_tteip_ttembr
HAVE      3012322 21231
      894521136 29

WANTstrataprocofficeopip
30cath1/31/31/31
30pcis2/31/31/31
30secho3/31/31/31
30tte2/311/312/31
30perfs2/31/31/31
30mpis./312/31/31
89cath4/296/29/29
89pcis5/29/29/29
89secho2/29/29/29
89tte11/29/29/29
89perfs3/29/29/29
89mpis/29/29/29

I tried proc tranpose but that does not work, then tried a data step with if statements creating a new row called office, then 1 op and the other ip. It does not look like the want data.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Here you go:

data want;

input strata    ofc_caths    ofc_pcis    ofc_secho    ofc_tte    ofc_perfs    op_caths    op_mpis    op_tte    ip_tte    mbr;

cards;

30    1    2    3    2    2    .    2    1    2    31

89    4    5    2    11    3    6    .    .    .    29

;

run;

data step1;

    set want;

    array vars(*) ofc: op: ip:;

    do i=1 to dim(vars);

        location=scan(vname(vars(i)), 1, "_");

        procedure=scan(vname(vars(i)), 2, "_");

        value=vars(i);

        value_display=put(value, 2.)||"/"||put(mbr, 3.);

        output;

    end;

    drop ofc: op: ip:;

run;

proc sort data=step1;

by strata  procedure location;

run;

proc transpose data=step1 out=want;

by strata procedure;

id location;

var value_display;

run;

View solution in original post

1 REPLY 1
Reeza
Super User

Here you go:

data want;

input strata    ofc_caths    ofc_pcis    ofc_secho    ofc_tte    ofc_perfs    op_caths    op_mpis    op_tte    ip_tte    mbr;

cards;

30    1    2    3    2    2    .    2    1    2    31

89    4    5    2    11    3    6    .    .    .    29

;

run;

data step1;

    set want;

    array vars(*) ofc: op: ip:;

    do i=1 to dim(vars);

        location=scan(vname(vars(i)), 1, "_");

        procedure=scan(vname(vars(i)), 2, "_");

        value=vars(i);

        value_display=put(value, 2.)||"/"||put(mbr, 3.);

        output;

    end;

    drop ofc: op: ip:;

run;

proc sort data=step1;

by strata  procedure location;

run;

proc transpose data=step1 out=want;

by strata procedure;

id location;

var value_display;

run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1036 views
  • 0 likes
  • 2 in conversation