Sentry Page Protection
Proc Format [1-2]
SAS Base Exam
SAS Base Exam
Proc Print
The PRINT procedure prints the data portion of a data set.
Example
Copy and run the CARRIER data set from the yellow box below.
Example
Copy and run the CARRIER data set from the yellow box below.
The CARRIER data set contains 6 variables.
- Order
- Date
- Length
- Width
- Height
- Weight
Let's run the PRINT procedure on this data set.
Example
Proc Print Data=Order;
Var Order Date Weight;
Run;
The PRINT procedure has a VAR statement that specifies the variables to be printed.
The variables ORDER, DATE and WEIGHT are printed on the output:
Variable Format
You can add a format statement to the PRINT procedure to change the display of the variable values.
Example
The variable WEIGHT is currently displayed with no decimal place.
Now, let's add a format statement to the PRINT procedure and change the display to 2 decimal places.
Example
Proc Print Data=Carrier;
Var Order Date Weight;
Format Weight 6.2;
Run;
The WEIGHT variable is now displayed with 2 decimal places.
[Note: the concept of format will be explained in details in later sections.]
Exercise
Print the data portion of the CARRIER data set. Display only the following variables:
Display both the HEIGHT and LENGTH variables in 1 decimal places.
- ORDER
- HEIGHT
- LENGTH
Display both the HEIGHT and LENGTH variables in 1 decimal places.
Need some help?
Fill out my online form.