Common errors in dealing with value labels

  • Author: admin
  • Filed under: Auto-cars
  • Date: Mar 12,2008

1.leaving off the period at the end of the format in a format statement, and

2.leaving off the dollar sign before a character format.  If you leave out the proc format code in a program using a permanent file where formats are defined SAS will require the formats be available fro use.  In this case you can either follow the instructions for including code (%include) above, or copy the proc format code into your current program.

3.You can also include the nofmterr option to allow the program to run with out errors. Another common error is to reference the format with a format statement before defining the format with proc format code.  Read the rest of this entry »


Labeling values is a two step process

  • Author: admin
  • Filed under: Auto-cars
  • Date: Mar 12,2008

First, you must create the label formats with proc format using a value statement. Next, you attach the label format to the variable with a format statement. This format statement can be used in either proc or data steps. An example of the proc format step for creating the value formats, forgnf and $makef follows.

PROC FORMAT; VALUE forgnf 0=”domestic” 1=”foreign” ; VALUE $makef “AMC” =”American Motors” “Buick” =”Buick (GM)” “Cad.” =”Cadillac (GM)” “Chev.” =”Chevrolet (GM)” “Datsun” =”Datsun (Nissan)”;RUN;
You may include any number of value statements to create label formats as needed. Since make is a variable that contains character values, when you define the formats for it you have to precede the format name with a $ so the format name becomes $makef. Additionally, for character variables the values of the variables must be enclosed in quotes.
Read the rest of this entry »


step to assign labels to the variables

  • Author: admin
  • Filed under: Auto-cars
  • Date: Mar 12,2008

Creating variable labels We use the label statement in the data step to assign labels to the variables.  You could also assign labels to variables in proc steps, but then the labelsonly exist for that step.  When labels are assigned in the data step they are available for all procedures that use that data set.

The following program assigns variable labels to rep78, mpg and foreign.
DATA  auto2;   SET auto;   LABEL  rep78  =”1978 Repair Record”          mpg    =”Miles Per Gallon”          foreign=”Where Car Was Made”;RUN;PROC CONTENTS DATA=auto2;RUN; Read the rest of this entry »


How to create and use labels in SAS

  • Author: admin
  • Filed under: Auto-cars
  • Date: Mar 12,2008

There are two main items that can be labeled, variables and values.once created these labels will appear in the output of statistical procedures and reports that you may produce from SAS. They are also displayed by some of the SAS/GRAPH procedures.
The program below reads the data and creates a temporary data file called auto

. The labeling shown in this module are all applied to this data file called auto.

DATA auto ; INPUT make $ mpg rep78 weight foreign ;CARDS;AMC 22 3 2930 0AMC 17 3 3350 0AMC 22 . 2640 0Audi 17 5 2830 1Audi 23 3 2070 1BMW 25 4 2650 1Buick 20 3 3250 0Buick 15 4 4080 0Buick 18 3 3670 0Buick 26 . 2230 0Buick 20 3 3280 0Buick 16 3 3880 0Buick 19 3 3400 0Cad. 14 3 4330 0Cad. 14 2 3900 0Cad. 21 3 4290 0Chev. 29 3 2110 0Chev. 16 4 3690 0Chev. 22 3 3180 0Chev. 22 2 3220 0Chev. 24 2 2750 0Chev. 19 3 3430 0Datsun 23 4 2370 1Datsun 35 5 2020 1Datsun 24 4 2280 1Datsun 21 4 2750 1;RUN;PROC CONTENTS DATA=auto;RUN; Read the rest of this entry »