Hello guys, anyone can help me to make this code more efficient(see code below), please not using sql: I would like to do something with the week12, week28, week40 and week64, try to do it more standard, because if I need to change the dataset new with different weeks (i.e week1, wek3, week5, week52), I would have to change manually these weeks..and it is no really efficient. something like week_i,where i=1 to 4 Any help? Thanks in advance. Please see the code below: data new; input visit &$6. treat &$7. pop :1. phase &$2.; cards; week12 placebo 1 I week28 placebo 1 II week40 drug 1 III week64 drug 1 IV week64 placebo 1 III week40 placebo 1 III week40 drug 1 I week12 drug 1 II week12 drug 1 II week28 placebo 1 II week28 placebo 1 II week40 placebo 1 III week40 placebo 1 IV week12 drug 1 IV week64 drug 1 III week64 drug 1 II week12 drug 1 I week12 placebo 1 I week64 placebo 1 II week28 placebo 1 III ; run; *summary of subjects by phase; proc summary data=new nway; class treat phase visit; var pop; output out=newsum(drop=_:) n=n; run; *summary of subjects by treat; proc summary data=new nway; class treat; var pop; output out=new0sum (drop=_:) n=n2; run; *merging the summaries; data newsumtotal; merge new0sum newsum; by treat; run; *transposing to get the final table; proc transpose data=newsumtotal out=newsumtotalt; by treat n2 phase; id visit; var n; run; *convert numeric variable to character (I want to make this part more efficient); data newf (drop=week12 week28 week40 week64); set newsumtotalt; _week12=put(week12,3.0)||' '||'('||put(week12/n2,percent6.2)||')'; _week28=put(week28,3.0)||' '||'('||put(week28/n2,percent6.2)||')'; _week40=put(week40,3.0)||' '||'('||put(week40/n2,percent6.2)||')'; _week64=put(week64,3.0)||' '||'('||put(week64/n2,percent6.2)||')'; run; data newfr (rename=(_week12=week12 _week28=week28 _week40=week40 _week64=week64) drop=_name_ ); retain treat n2 phase _week12 _week28 _week40 _week64; set newf; run; V
... View more