598 *********************************************; 599 * f=sasmanual\clinq_manip.sas *; 600 * *; 601 * Clinical data set questions: *; 602 * IV. Data Manipulation (new variables) *; 603 *********************************************; 604 605 options linesize=min; 606 607 libname mydir 'c:\My Documents\My SAS Files\sasmanual\data' 607! ; NOTE: Libref MYDIR was successfully assigned as follows: Engine: V7 Physical Name: c:\My Documents\My SAS Files\sasmanual\data 608 609 proc format; 610 value ratef low-69 = '1' 611 70-85 = '2' 612 86-high= '3'; NOTE: Format RATEF is already on the library. NOTE: Format RATEF has been output. 613 614 value $ratel '1' = '<70' 615 '2' = '70-85' 616 '3' = '86 and over'; NOTE: Format $RATEL is already on the library. NOTE: Format $RATEL has been output. 617 run; NOTE: PROCEDURE FORMAT used: real time 0.00 seconds 618 619 data clin; 620 set mydir.clinical; 621 622 /* QUESTION 1 */ 623 bpratio = round((sbp/dbp),0.1); 624 625 /* QUESTION 2 */ 626 prim_sub = substr(prim_dx,2,1); 627 628 /* QUESTION 3 */ 629 bpnorm = (65<=dbp<=90) and (100<=sbp<=140); 630 631 /* QUESTION 4 */ 632 rateput=put(hr,ratef.); 633 634 if hr<70 then rateif='1'; 635 else if 70<=hr<=85 then rateif='2'; 636 else if hr>85 then rateif='3'; 637 638 run; NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 623:11 1 at 623:21 NOTE: The data set WORK.CLIN has 34 observations and 16 variables. NOTE: DATA statement used: real time 0.15 seconds 639 640 proc freq data=clin; 641 tables bpratio; 642 title1 'The simulated clinical data from the SAS manual'; 643 title2 'Question 1 - Create blood pressure ratio variable'; 644 run; NOTE: PROCEDURE FREQ used: real time 0.16 seconds 645 646 proc freq data=clin; 647 tables prim_sub * prim_dx /list missing; 648 title2 'Question 2 - Create new variable from prim_dx'; 649 run; NOTE: PROCEDURE FREQ used: real time 0.17 seconds 650 651 proc freq data=clin; 652 tables bpnorm * sbp * dbp /list missing; 653 title2 'Question 3 - Create new 1/0 blood pressure 653! variable'; 654 run; NOTE: PROCEDURE FREQ used: real time 0.44 seconds 655 656 proc freq data=clin; 657 tables rateif rateput; 658 title2 'Question 4 - Create new grouped variable for bp'; 659 format rateif rateput $ratel.; 660 run; NOTE: PROCEDURE FREQ used: real time 0.16 seconds