Project 9 (practice in-class final)
Turn-in 4pm
Please put all solutions in sequential order into one single SAS program with the name of the SAS program being Final_stat6110_yourname.sas, where “yourname” is replace with your last name. In the problems in which I provide some code be sure to include my code because your code won’t work unless mine is run first. You cannot discuss this final with anyone but me, you cannot use any outside resources (especially not the internet or books), but you can use the SAS help screens. No other resource can be used, other than the SAS help screens. Failure to turn the take-home portion by the due date and time, will result in mandatory taking of the in-class final at the scheduled final time.
- Write DATASTEP that imports the following data, using DATALINES, and INFORMAT AND FORMAT statements. The variables are Transaction (8 digit transaction number), Date (date of transaction) and Amount (dollar amount of the transaction).
0074309801/15/2001$1,003.59
1028754301/17/2001$672.05
3320899201/19/2001$702.77
0345900601/19/2001$1,209.61
- Write a DATASTEP that imports the following data, using DATALINES and INFORMAT and FORMAT statements. The variables are Name (name of the student) and Exam1, Exam2, Exam3 and Amount_Due.
"Johnson,Berty",3.8,,,3.9,$500
"DeChang,Dan",,3.0,3.6,3.5,$400
"Elanozo,Dan",4.0,3.8,3.9,4.0,$300
- The following SAS code creates a tab delimited data set. After running this code, write a DATASTEP , using the INFILE statement, to import the resulting dataset into a SAS dataset (table3.txt). Also in that datastep, include the appropriate statements to fix the following typos: For the first observation, the year in the data is supposed to be 1998, not 1999. For the second observation Anthony is misspelled as “Anhtony” .
DATA_null_;
FILE'I:\stat6110\project9\table3.txt';
PUT"Susan B. Anthony"'09'x"05/28/1999"'09'x"Raleigh";
PUT"Suzy B. Anhtony"'09'x"5/1/1998"'09'x"Wake Forest";
RUN;
- The following SAS code creates a delimited data set, with the variable names at the top and two observations. Note: the resulting file has exclamation point as the delimiter. After running this code, use PROC IMPORT to create a SAS dataset properly importing the data file that was just created .
data_null_;
file'I:\stat6110\project9\pipe.txt';
put"y1!y2!y3!y4";
put"11!22!.! ";
put"111!.!333!banana";
run;
- Concatenate the following two datasets, “data1” and “data2” into one dataset called “data1_2”.
DATA data1;
input name $ age;
datalines;
Joe 36
Jae 21
Jon 30
;
DATA data2;
INPUT name $ agesteam;
DATALINES;
Dan 33 1
Jace 40 2
Michelle 60 3
Ty 26 4
;
- Merge the following two datasets, “data_a” and “data_b”, into one dataset called “data_c”. Notice there is a common ID variable in both datasets.
datadata_a;
input id $ food $;
datalines;
aHotdog
a Hamburger
b vegetable
c fruit
;
datadata_b;
input id $ style $;
datalines;
ayellow
b black
c wild
c oaks
clacy
;
- Run the following code to produce the dataset Problem7. Write a DATASTEP that creates a dataset called Problem7_b, which usea SAS ARRAYand a DO LOOP to replace missing values (“.”) with zero (“0”). Note: you must use the “_numeric_” option in the ARRAY declaration, instead of a variable list, and you must let SAS determine the dimension of the array by using the “*” wildcard.
DATAproblem7;
INPUT x1 x2 x3;
DATALINES;
1 1 4
. 0 8
8 8 .
2 7 2
9 2 1
;
- Run the following code to produce the dataset Region. Write a DATASTEP that creates a dataset called Region_final, which use a SAS ARRAY and a DO LOOP to replace zeros (“0”) in the “region” dataset with a missing value (“.”). Note: you must use the “_numeric_” option in the ARRAY declaration, instead of a variable list, and you must let SAS determine the dimension of the array by using the “*” wildcard.
DATA Region;
INPUT Region quarter1 quarter2 quarter3 quarter4;
DATALINES;
601 3 0 4 9
610 8 7 5 8
700 0 0 6 7
800 6 5 6 9
901 3 8 7 0
;
- Go to the SAS help screens to learn about the SAS character function called SCAN. Run the following dataset to create the dataset “NAMES”. Write a datastep that creates a dataset called NAME_SCAN from the existing SAS dataset NAME, and produces a new variable called LAST, which represents the last name extracted from the variable FullName, using the SCAN function.
DATA NAME;
INPUT @1FullName$20.
@21 PHONE $13.;
DATALINES;
Jeff W. Snoker (908)782-4382
Raymond Albert (732)235-4444
Steven J. Foster (201)567-9876
Jose Romerez (516)593-2377
;