BookmarkSubscribeRSS Feed
devarayalu
Fluorite | Level 6

Please help in this regard.

In a clinical trial two treatments with 1(n=10) and 2(n=10) with a total of 20 subjects.

Suppose the indput AE dataset is:

subidtrtSOCPFT
0212Gastrointestinal disordersConstipation
0311Gastrointestinal disordersHypoaesthesia oral
0651Gastrointestinal disordersParaesthesia oral
1032Gastrointestinal disordersAbdominal pain upper
0202Eye disordersConjunctivitis
0871Eye disordersOcular hyperaemia
0871Eye disordersEye swelling
0881Eye disordersEye swelling

Final dataset should be like this?

Variable12Total hlt_indx type
Gastrointestinal disorders2020201 hlt
Constipation01051 llt
Hypoaesthesia oral10051 llt
Paraesthesia oral10051 llt
Abdominal pain upper01051 llt
Eye disorders3010202 hlt
Conjunctivitis01052 llt
Ocular hyperaemia10052 llt
Eye swelling200102 llt

Thank you very much in advance

1 REPLY 1
art297
Opal | Level 21

I don't have time to optimize the following code, but it appears to produce your wanted result:

data have;

  informat subid $3.;

  informat soc $30.;

  informat pft $30.;

  input subid trt SOC & PFT &;

  cards;

021 2 Gastrointestinal disorders Constipation

031 1 Gastrointestinal disorders Hypoaesthesia oral

065 1 Gastrointestinal disorders Paraesthesia oral

103 2 Gastrointestinal disorders Abdominal pain upper

020 2 Eye disorders Conjunctivitis

087 1 Eye disorders Ocular hyperaemia

087 1 Eye disorders Eye swelling

088 1 Eye disorders Eye swelling

;

data want (keep=variable _: total hlt_indx type);

  set have;

  by soc pft notsorted;

  retain _1 _2 grand_total grand_1 grand_2 type;

  if first.soc then do;

    type='lit';

    grand_total=0;

    grand_1=0;

    grand_2=0;

    hlt_indx+1;

  end;

  if first.pft then do;

    _1=0;

    _2=0;

  end;

  _1=ifn(trt=1,sum(_1,10),sum(_1,0));

  _2=ifn(trt=2,sum(_2,10),sum(_2,0));

  if last.pft then do;

    total=sum(_1,_2)/2;

    grand_total=sum(grand_total,total);

    grand_1=sum(grand_1,_1);

    grand_2=sum(grand_2,_2);

    variable=pft;

    output;

  end;

  if last.soc then do;

    type='hlt';

    total=grand_total;

    _1=grand_1;

    _2=grand_2;

    variable=soc;

    output;

  end;

run;

proc sort data=want;

  by hlt_indx type;

run;

data want;

  retain variable _1 _2 Total hlt_indx type;

  set want;

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
  • 662 views
  • 0 likes
  • 2 in conversation