## data step

Super Contributor
Posts: 320

# data step

Hi I need your help in my code.

In my data (a1) two variables present.

variables:Cohortcd            events

2                        1

3                         1

5.2                      2

5.1                      1

Total                      5

Since it doesnot the cohortcd=1 and 4. I created a dataset (a2) with cohortcd=1 and 4 and events=0.

eg:data a2;
input COHORTCD \$ events;
datalines;
1 0
4 0
;

Using the program: I merged.

data a3;
set a1 a2;
run;

Then I perfpormed Proc transpose and calculted percentages with following code.

pct1=put(round(_1/1*100,1),5.1);
pct2=put(round(_2/1*100,1),5.1);
pct3=put(round(_3/1*100,1),5.1);
pct4=put(round(_4/1*100,1),5.1);
pct5=put(round(_5D2/2*100,1),5.1);
pct6=put(round(_5D1/1*100,1),5.1);
pct7=put(round(Total/5*100,1),5.1);

cnt_pct1=catx(' ',_1,('(' || put(pct1, 3.) || '%)'));
cnt_pct2=catx(' ',_2,('(' || put(pct2, 3.) || '%)'));
cnt_pct3=catx(' ',_3,('(' || put(pct3, 3.) || '%)'));
cnt_pct4=catx(' ',_4,('(' || put(pct4, 3.) || '%)'));
cnt_pct5=catx(' ',_5D2,('(' || put(pct5, 3.) || '%)'));
cnt_pct6=catx(' ',_5D1,('(' || put(pct6, 3.) || '%)'));
cnt_pct7=catx(' ',Total,('(' || put(pct7, 3.) || '%)'));
run;

After this using following code I ran proc report.

OPTIONS nodate nonumber;
ods listing close;
ods escapechar="^";
t
options orientation=landscape formchar="|----|+|---+=|-/\<>*";

ods rtf file="C:\Users\vvemireddy\Desktop\ae_1.rtf" style=journal;
column grp aebodsys aetext cnt_pct1 cnt_pct2 cnt_pct3 cnt_pct4 ("5" "_______________" cnt_pct5 cnt_pct6) cnt_pct7;
define grp/order noprint;
define aebodsys/order noprint;

define aetext/ display 'Adverse Event' style(column)={asis=on cellspacing=.25pt just=left};
define cnt_pct1 / "1" style(column)={cellspacing=.25pt just=left};
define cnt_pct2/ "2" style(column)={cellspacing=.25pt just=left} ;
define cnt_pct3/ "3" style(column)={cellspacing=.25pt just=left};
define cnt_pct4/"4" style(column)={cellspacing=.25pt just=left} ;
define cnt_pct5/"5.2" style(column)={cellspacing=.25pt just=left};
define cnt_pct6/"5.1" style(column)={cellspacing=.25pt just=left} ;
define cnt_pct7/"Total" style(column)={cellspacing=.25pt just=left} ;
compute after grp/style={protectspecialchars=off};
n+1;
len=ifn(n=1,20,0);
dummy='\brdrt\brdrs';
line dummy \$varying20. len;
endcomp;
run;
ods rtf close;

I am  getting expected results for the variables in the a1 dataset, but not for a2 dataset variables I added to a1 dataset. I am unable to attach the  proc report results in RTF format. I am going to show as best as I can what my issue is. In other formats I am getting expected results. But RTF format I am not getting expected results for the a2 variables (1 and 4) which I added to a1 Please check vaiable 1 and 4. Please help

Results in other format

Number of TEAEs

0 ( 0%)    1 (100%)     1 (100%)    0 ( 0%)         2 (100%)        1 (100%)         5 (100%)

Results in RTF format

 Adverse Event 1 2 3 4 5.2 5.1 Total Number of TEAEs 0 ( 0%) 1 (100%) 1 (100%) 0 ( 0%) 2 (100%) 1 (100%) 5 (100%)
Posts: 1,147

## Re: data step

Hi

could you please try to replace the below code

cnt_pct1=catx(' ',_1,('(' || put(pct1, 3.) || '%)'));
cnt_pct2=catx(' ',_2,('(' || put(pct2, 3.) || '%)'));
cnt_pct3=catx(' ',_3,('(' || put(pct3, 3.) || '%)'));
cnt_pct4=catx(' ',_4,('(' || put(pct4, 3.) || '%)'));
cnt_pct5=catx(' ',_5D2,('(' || put(pct5, 3.) || '%)'));
cnt_pct6=catx(' ',_5D1,('(' || put(pct6, 3.) || '%)'));
cnt_pct7=catx(' ',Total,('(' || put(pct7, 3.) || '%)'));

with

cnt_pct1=cat(_1,' (', put(pct1, 3.),'%)');
cnt_pct2=cat(_2,' (', put(pct2, 3.),'%)');
cnt_pct3=cat(_3,' (', put(pct3, 3.),'%)');
cnt_pct4=cat(_4,' (', put(pct4, 3.),'%)');
cnt_pct5=cat(_5D2,' (', put(pct5, 3.),'%)');
cnt_pct6=cat(_5D1,' (', put(pct6, 3.),'%)');
cnt_pct7=cat(Total,' (',put(pct7, 3.),'%)');

Please try and let me know if it helps.
Thanks,
Jag
Super Contributor
Posts: 320

## Re: data step

Thank you for help. Your code still results in same output for variables 1 and 4 in RTF format as my code.

Super User
Posts: 9,599

## Re: data step

Oh, I see, you mean in your output RTF the text is being wrapped - makes sure you set a cokumn width that fits for each column:

define cnt_pct1 / "1" style(column)={cellwidth=3cm cellspacing=.25pt just=left};

^                 ^

This should prevent the wrapping.  However all my questions still stand.

Super Contributor
Posts: 320

## Re: data step

Thank you very much. That works.

Super User
Posts: 9,599

## Re: data step

Sorry, there is a lot here which is not clear to me.  How do you start with a dataset of counts, is this some counting you have done previously - i.e. do those values actually equal 100% for each cohort?  Secondly, in  clinical outputs percentage is normally of the format 5.2.  If your assuming that they are a hundred, why not just create the string before transposing the data, saves re-typing all the code:

data have;
input Cohortcd events;
pct=cat(strip(put(events,best.)),' (',put(ifn(events=0,0,100),3.),'%)');
datalines;
1 0
2 1
3 1
4 0
5.2 2
5.1 1
;
run;
proc transpose data=have out=want;
var pct;
id cohortcd;
idlabel cohortcd;
run;

Though I have to say, I don't see the point in this out at all, TAE's should be cohort down the page and treatment arm across the page, with the values being counts of TAEs within each treatment/cohort.  Percentage doesn't make any sense as you have neither littel or big N.  So you would have number of subjects with TAE as a number and percentage of number of sujects within population, but not individual TAE's.

Super User
Posts: 6,751