05-25-2017 05:59 PM
In the ouput result of the below program (in the grey box), I need to have zero count(NS=0) when there are no subjects present for the treatment.
data one; input id trt$ sflag$; datalines; 1 45mg Y 2 30mg Y 3 15mg N 4 30mg Y 5 45mg Y 6 plcebo Y 7 45mg Y ; PROC SQL; create table two as select count(distinct id) as NS,trt from one where sflag='Y' group by trt; quit;
I think I can get the output by two proc transpose and two datsteps inbetween. But please suggest me if any better way to do this. Thank you very much
program I am running to get output I need
proc transpose data=two out=three(drop=_NAME_);
array data _15mg _30mg _45mg placebo;
do over data;
if missing(data) then data=0;
TOTAL=_15mg + _30mg + _45mg ;
proc transpose data=four out=five;
var placebo _15mg _30mg _45mg total ;
05-25-2017 06:12 PM
It can be done simpler. But what if your data looked like this?
data one; input id trt$ sflag$; datalines; 1 45mg Y 2 30mg Y 3 15mg N 4 30mg Y 5 45mg Y 6 plcebo Y 7 45mg Y 8 15mg Y ;
So that you also had a 15mg observation with sflag='Y'. What would your desired output look like then?