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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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