Sample 24813: Saving Labels and Formats in SAS Data Sets
Programmers are always looking for ways to save time, especially during periods of crunch-time. One technique I've found useful during these periods is assigning variable labels and formats with all my SAS data sets. It's a fairly easy process, although it does require a little extra time to initially set-up. But the rewards of having assigned them generally outweigh any initial time and cost in their creation.
I like to think of it as part of the data preparation process - it's an approach that rewards over and over. Sunil Gupta of Gupta Programming offers these suggestions on using labels and formats:
"Labels and formats are stored with many of our important SAS data sets to minimize processing time. A reason for using this technique is that many popular procedures use stored formats and labels as they produce output, eliminating the need to assign them in each individual step. This provides added incentives and value for programmers and end-users, especially since reporting requirements are usually time critical."
The following example illustrates how a LABEL statement can be assigned to two variables in a data set:
|
data libref.patients ;
infile 'raw-data-file' missover ;
input @1 patname $25.
@30 age 3. ;
label patname = 'Patient Name'
age = 'Patient Age' ;
run ;
|
|
The following example illustrates how a FORMAT statement can be assigned to a date value:
|
|
data libref.patients ;
infile 'raw-data-file' missover ;
input @40 dob mmddyy10. ;
format dob mmddyy10. ;
run ;
|
|
This tip was provided by Kirk Paul Lafler, Software Intelligence Corporation. If you would like more information or have any questions about this tip, please contact: Kirk Lafler, Software Intelligence Corporation at the following e-mail address KirkLafler@cs.com.
|
data libref.patients ;
infile 'raw-data-file' missover ;
input @1 patname $25.
@30 age 3. ;
label patname = 'Patient Name'
age = 'Patient Age' ;
run ;
data libref.patients ;
infile 'raw-data-file' missover ;
input @40 dob mmddyy10. ;
format dob mmddyy10. ;
run ;
This sample shows how to assign variable labels and formats.
| Type: | Sample |
| Topic: | Non SAS Authors ==> Kirk Paul Lafler SAS Reference ==> Formats SAS Reference ==> DATA Step
|
| Date Modified: | 2005-12-08 11:34:37 |
| Date Created: | 2004-10-08 08:51:50 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |