Description
For this activity you will create a SAS program and upload that program to
wolfware. Be sure that your SAS file adheres to the SAS file submission guidelines
(available on wolfware).
The data set(s) for this activity are available in the assignment 7 link.
To Do – Write code corresponding to each step below, that is, do not change the
code for step 1 to do step 2 (you can copy and paste it so you don’t have to retype
it, but leave the answer to each step in your program):
1. Create a new library called “Week7”.
2. Read in the FastFood.csv file with a single DATA step and the following
specifications:
a) Save the data set as “FastFood” in the Week7 library.
b) Use the proper informat for the “Price” variable.
c) Make a new variable “Ratio” which is a relative ratio of Sodium to the standard
1,500mg daily allowance. That is, create a new variable that is the amount of
Sodium divided by 1,500.
d) Create a new variable that hides the brand names except the initial character.
You may find the SUBSTR function useful (see the SAS help).
(“McDonalds” and “Burger King” should be “M” and “B”, respectively)
e) A new categorical variable would be created by the following code.
IF Ratio > 0.8 THEN SodiumLevel= “Salty” ;
ELSE SodiumLevel=”Healthy”;
The new variable will have values that are truncated. Place a comment below
this DATA step about the cause and how to fix it.
f) Correct (or add) SAS code to prevent truncation in e).
g) Display the “Ratio” variable in percentage format.
h) Display the “Price” variable with dollar sign and two digits right to decimal
point.
i) Display the “Calories” variable with comma. (e.g. 2,400).
3. Using the data set you created above write a single DATA step and a PROC step to
do the following:
In a DATA step:
a) Create a new data set called McDonalds utilizing the SET and WHERE
statements. The new data set should only include McDonalds’ data.
b) Make a new variable called “Price_Dollar” which is the smallest integer that is
greater than or equal to the “Price” value.
(You may see CEIL function is useful.)
c) Keep only “SodiumLevel” and “Price_Dollar” variables in the final dataset.
d) Display a dollar sign for “Price_Dollar” variable.
In a PROC step:
e) Draw a vertical bar chart like the following plot.
4. Using the data set from part 2, a single DATA step, and a single PROC STEP
In a DATA step:
a) Create a new data set called BurgerKing that includes only Burger King data
utilizing the IF statement with THEN DELETE.
b) Make a new variable called “MedianFat” which is the median of the three fatrelated variables.
c) Drop the three fat variables.
In a PROC step:
d) Draw a scatter plot with “MedianFat” on x-axis and “Calories” on y-axis.

