11-17-2013 11:21 PM
I have several variables and would like to change the format of one of the variables. I have tried the following code but am having some trouble getting it to work
The variable I am trying to change to format 8. is called firmid
format firmid 8.;
Any help is appreciated
11-18-2013 11:47 AM
Proc datasets will let you change characteristics of variables such as label and fomrat in place without creating a new data set.
proc datasets library=<library the dataset is in> ;
format firmid 8.; /*put as many variable name format combinations as you need here*/
11-18-2013 03:05 PM
Define "efficient" in this case. I think using MODIFY you're going through all of the observations in the data set, so execution time is going to depend on the number of records. With Proc datasets only the data set descriptor is affected and it takes basically the same amount of time to run with 10 records or 10billion.
Modify is intended to modify, append or delete observations from a data set, in other words change the content.
It is worth remembering the note in the SAS documentation:
Damage to the SAS data set can occur if the system terminates abnormally during a DATA step that contains the MODIFY statement.
Proc Datasets as called in this above manner only changes the descriptions of the variables: name, format, informat or label and will not actually change values or the number of observations.