Convince yourself that the variable names sex and b_date have been changed as advertised to gender and birth, respectively. Review the output from the PRINT procedure. Where dsname is the data set name and o1 and o2 are the old variable names, and n1 and n2 are the new variable names. So, in general, the syntax, when applied to a DATA statement, should look like this: DATA dsname (RENAME = (o1=n1 o2=n2. The variable names must also be placed in parentheses. The entire RENAME= option must be contained in parentheses immediately following the data set to which you want the name changes to apply. Hence, when we subsequently calculate the subjects' ages ( age) in the DATA step, we must refer to the new variable name birth.Īgain, pay particular attention to the syntax of the RENAME= option. Instead, SAS recognizes the variable names gender and birth. Therefore, all programming statements within the DATA step must refer to the old variable name.īecause the RENAME= option appears in the SET statement, SAS no longer recognizes the variable name sex as the gender, nor b_date as the birth date, of the subject. If the RENAME= option appears in the DATA statement, then the new variable name takes effect only when the data are written to the SAS data set.Therefore, all programming statements within the DATA step must refer to the new variable name. If the RENAME= option appears in the SET statement, then the new variable name takes effect when the program data vector is created.The effect of the RENAME= option depends on where it appears: , newk are the corresponding new variable names. oldk are the variable names as they appear in the data set that precedes the RENAME= option, and new1, new2. The format of the RENAME= option is: RENAME = (old1=new1 old2=new2. As its name suggests, the RENAME= option allows you to change the variable names within a SAS data set. To do so, you'll want to use the RENAME= option. There may be occasions in which you want to change some of the variable names in your SAS data set.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |