From: papu on 20 Jun 2010 19:48 Hi All, Can anyone let me know how to write a perl script or ksh script to change proc format in SAS to if-then-else. Please see below for example. Thanks for your help. /*OLD FILE*/ %let _V0 = var1; /* xnbntl75_n */ %let _V1 = var2; /* pct_pay_bal_cyc_1 */ proc format; value V_0_f /* var1 */ 0 -< 1 = "38.6375" 1 -< 2 = "29.8241" 2 -< 3 = "18.8390" 3 -< 4 = "12.8211" 4 -< 5 = "7.8781" 5 -< 8 = "1.4283" 8 - high = "-6.4817" other = "24.2959" ; value V_1_f /* var2 */ 0 -< 3.52 = "10.5909" 3.52 -< 10.87 = "25.4922" 10.87 -< 23.68 = "36.4572" 23.68 -< 99.84 = "37.4047" 99.84 - high = "46.0035" other = "24.2959" ; run; data &SCORE_DS; set &INPUT_DS; /*********************************************************/ /* Note: applying score weight formats to scorecard vars */ /*********************************************************/ cbr_score0 = input ( put( &_V0, V_0_f. ), 8. ); /* var1 */ cbr_score1 = input ( put( round( &_V1, &ROUND_PRECISION ), V_1_f. ), 8. ); /* var2 */; cbr_scaledScore = sum( of cbr_score0-cbr_score1 ); run; endrsubmit; /*NEW FILE*/ data &SCORE_DS; set &INPUT_DS; IF 0 <= var1 < 1 THEN cbr_score0 = "38.6375"; ELSE IF 1 <= var1 < 2 THEN cbr_score0 = "29.8241"; ELSE IF 2 <= var1 < 3 THEN cbr_score0 = "18.8390"; ELSE IF 3 <= var1 < 4 THEN cbr_score0 = "12.8211"; ELSE IF 4 <= var1 < 5 THEN cbr_score0 = "7.8781"; ELSE IF 5 <= var1 < 8 THEN cbr_score0 = "1.4283"; ELSE IF 5 <= var1 THEN cbr_score0 = "-6.4817"; ELSE cbr_score0 = "24.2959"; IF 0 <= var2 < 3.52 THEN cbr_score1 = "10.5909"; ELSE IF 3.52 <= var2 < 10.87 THEN cbr_score1 = "25.4922"; ELSE IF 10.87 <= var2 < 23.68 THEN cbr_score1 = "36.4572"; ELSE IF 23.68 <= var2 < 99.84 THEN cbr_score1 = "37.4047"; ELSE IF 99.84 <= var2 THEN cbr_score1 = "46.0035"; ELSE cbr_score1 = "24.2959"; cbr_scaledScore = sum( of cbr_score0-cbr_score1 ); run; endrsubmit;
|
Pages: 1 Prev: (sh/bash) How to check for a string matching -*? Next: separating a file into pairs of words |