Tuesday, March 11, 2014

SAS- Proc Format


Formatting number, date, labels etc in SAS programming

AS PROGRAMS FOR ABSOLUTE BEGINNERS BY AJEET KUMAR


/* Proc Format Program Number: 1 */
proc format;
value $ genderx 'M' = 'Male'
            'F' = 'Female'
            other = 'Missing';
run;
proc print data = class ;
var name Gender ;
format Gender $genderx.;
run;

/* Proc Format Program Number: 2 */
proc format;
value $ genderx 'M' = 'Male'
            'F' = 'Female'
            other = 'Missing';
value salaryx   10000 <- 50000 = 'LOW'
            50000 <- 70000 = 'MEDIUM'
            70000 <- 99999 = 'HIGH'
            other = 'Error' ;
run;
proc print data = class ;
var name Gender salary ;
format Gender $genderx. salary salaryx.;
run;

/* Proc Format Program Number: 3 */
libname priyanka "D:\SAS Webcom";
proc format library=priyanka;
value $ genderx 'M' = 'Male'
            'F' = 'Female'
            other = 'Missing';
value salaryx   10000 - 50000 = 'LOW'
            50000 - 70000 = 'MEDIUM'
            70000 - 99999 = 'HIGH';
run;

/* Proc Format Program Number: 4 */
options fmtsearch=(priyanka) ;
libname priyanka "D:\SAS Webcom";
proc print data = class ;
format gender $genderx. ;
run;

/* Proc Format Program Number: 5 */
options fmtsearch=(priyanka) ;
libname priyanka "D:\SAS Webcom";
proc print data = class ;
format gender $genderx. ;
run;

No comments:

Post a Comment

Hot Topics