Previous Page | Next Page

SAS Variables

Aligning Variable Values

In SAS, numeric variables are right-aligned and character values are left-aligned. You can further control their alignment by using a format.

However, when you assign a character value in an assignment statement, SAS stores the value as it appears in the statement and does not perform any alignment. Output from the PRINT Procedure illustrates the character value alignment produced by the following program:

data aircode;
   input city $1-13;
   length airport $ 10;
   if city='San Francisco' then airport='SFO';
      else if city='Honolulu' then airport='HNL';
      else if city='New York' then airport='JFK or EWR';
      else if city='Miami' then airport='   MIA    ';
   datalines;
San Francisco
Honolulu
New York
Miami
;

proc print data=aircode;
run;

This example produces the following output:

Output from the PRINT Procedure

                      The SAS System                             

             OBS    CITY              AIRPORT

              1     San Francisco    SFO
              2     Honolulu         HNL
              3     New York         JFK or EWR
              4     Miami               MIA

Previous Page | Next Page | Top of Page