STAT 3094: SAS Base Programming In-Class #02 (Worth 10 points)
Instructions & Scenario
This assignment is due in the form of a SAS program called LastNameFirstInitial_IN2. When complete cut and paste your SAS program and comments into a WORD file (EG. SmithE_IN2.doc). When you complete the assignment upload the file to your CANVAS Assignment Drop Box by the due date and time. Mark all problems clearly in a comment such as /*Problem 1*/. Do collaborate with your team but submit your individual program.
Here we work with
1. Missing data and conversion
2. Use of if statement to select cases 3. Rounding numbers when printing 4. Sorting data
5. Formats
For the first set of problems, go to CANVAS and download the permanent SAS dataset named passngrs onto your external drive. Then, (optionally) create a folder on your external drive called IN_02 and put the SAS dataset in there. Create an ia library to access the SAS dataset. This dataset represents a summary of flights from International Airlines. Add comments to each relevant line of code to indicate what you are doing.
Exercises
2.
3.
1. Make sure that all output does not display the date and the page numbers, but the title contains your first and last name, “STAT 3094” on the next line, and “Inclass #2” on the third line. Adjust the line size to allow for 100 characters and the page to allow for 60 lines. Be sure to add comments about the executable lines. (IE use the options and title statement to format output from the program).
Create another (ie a new) permanent SAS dataset called prob2 located in the same library that stores a zero for missing business class values. Apply shortly-worded permanent labels to each of the SAS variables. Use the or comparison operator to keep those flights in the SAS dataset whose
destination is Anchorage or Seattle. Print this dataset in the output window.
Create another permanent SAS dataset called prob3 located in the same library that stores a
zero for missing business class values. Use the in operator this time to keep those flights in the
SAS dataset whose destination is Anchorage or Seattle. Print this dataset in the output window
using temporary SAS labels that you used in the previous problem. (Hint: if BClass = ‘.’ then BClass = 0; if dest in (‘ANC’,’SEA’);).
4. The data set EMAP data.sas has chemistry measurements from estuaries in Virginia from 1993. The data was originally a text file but we want to convert it to a permanent SAS data set.
a. The variables are listed with short names. Use a label statement to assign the longer names to variables that will be used in analyses.
Use the following names
STA_NAME: Station name
DATE: Sample collection date
DO: Dissolved oxygen conc
TEMP: Temperature (C) at the surface
SAL: Salinity (ppt) at the surface
PH: pH (units) at the surface
FLR: Fluorescence at the surface
TRANS: Transmissivity (%) at the surface
PAR: PAR (mE/m2/s) at the surface
DENS: Density (Sigma t) at the surface
SUSP: Total suspended solids conc
b. Make the information above the data a comment so it will not affect the reading of the data.
c. Read in the data and store it as a permanent SAS data set. Refer to the library as emap and the data set as Virginia. Read in the date variable as mmddyy. Note that you need to make sure SAS reads station as a character variable and use the @ to specify a location where the date record starts. So you need to use the statement @12 DATE yymmdd – then the other variables should be ok as they are.
d. Print out 10 observations. Note that the labels are not listed. Print the date with a format mmddyy10. Print the data with labels.
e. Compute means for the variables DO through SUSP. Note that labels are now part of the results.