- 140/90
- 90/68
- 190/100
- 100/066
- 098/060
现在怎样把bp变成如下两个变量 sbp、dbp
- sbp dbp
- 140 90
- 90 68
- 190 100
- 100 66
- 98 60
以下过程可以转换,但是太长了,有无简单方法?
- data a;
- input bp $7.;
- cards;
- 140/90
- 90/68
- 190/100
- 100/066
- 098/060
- ;
- run;
- data a; set a;
- if length(bp)=6 then sbp=substr(bp,1,3);
- else if length(bp)=5 then sbp=substr(bp,1,2);
- else if length(bp)=7 then sbp=substr(bp,1,3);
- if length(bp)=6 then dbp=substr(bp,5,2);
- else if length(bp)=5 then dbp=substr(bp,4,2);
- else if length(bp)=7 then dbp=substr(bp,5,3);
- sbp=input(sbp,3.);
- dbp=input(dbp,3.);
- run;
- proc print data=a; run;