Homework 1 SolutionsOutputOutput90-776 Manipulation of Large Data SetsHomework 1 Solutions1) Program/*U:\CLASS\90776\PROGRAMS\HW1P1.SAS performs the tasks in hw 1, problem 1*//* by Rob Greenbaum*//* date 2/8/1999*//* The program creates a permanent SAS data set containing the gallup data: u:\class\90776\data\gallup.sd2 */libname classdat 'u:\class\90776\data';filename galltxt 'u:\class\90776\data\gallup.txt';/* a. Bring in the ascii data and save as u:\class\90776\data\gallup.sd2*/data classdat.gallup; infile galltxt; input location age race gend educ emp wage hours weeks salary income disloc train monthu rate;RUN;/* b. display contents*/PROC CONTENTS data= classdat.gallup;RUN;/* b. descriptive stats of all variables*/PROC MEANS data = classdat.gallup;RUN; OutputThe SAS System 15:47 Monday, March 8, 1999 2 CONTENTS PROCEDURE Data Set Name: CLASSDAT.GALLUP Observations: 957 Member Type: DATA Variables: 15 Engine: V612 Indexes: 0 Created: 15:49 Monday, March 8, 1999 Observation Length: 120 Last Modified: 15:49 Monday, March 8, 1999 Deleted Observations: 0 Protection: Compressed: NO Data Set Type: Sorted: NO Label: -----Engine/Host Dependent Information----- Data Set Page Size: 8192 Number of Data Set Pages: 15 File Format: 607 First Data Page: 1 Max Obs per Page: 68 Obs in First Data Page: 49 -----Alphabetic List of Variables and Attributes----- # Variable Type Len Pos ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 2 AGE Num 8 8 12 DISLOC Num 8 88 5 EDUC Num 8 32 6 EMP Num 8 40 4 GEND Num 8 248 HOURS Num 8 56 11 INCOME Num 8 80 1 LOCATION Num 8 0 14 MONTHU Num 8 104 3 RACE Num 8 16 15 RATE Num 8 112 10 SALARY Num 8 72 13 TRAIN Num 8 96 7 WAGE Num 8 48 9 WEEKS Num 8 64 The SAS System 15:47 Monday, March 8, 1999 3 Variable N Mean Std Dev Minimum Maximum --------------------------------------------------------------------- LOCATION 957 6.4649948 0.7246968 5.0000000 7.0000000 AGE 957 37.7847440 12.8099912 16.0000000 77.0000000 RACE 957 1.1671891 0.5267427 1.0000000 4.0000000 GEND 957 0.5047022 0.5002393 0 1.0000000 EDUC 957 6.4514107 1.4086518 3.0000000 8.0000000 EMP 957 0.9341693 0.2481156 0 1.0000000 WAGE 957 12.0452769 13.0323460 0 227.2700000 HOURS 957 37.3322884 14.9204422 0 100.0000000 WEEKS 957 45.0334378 14.1295904 0 52.0000000 SALARY 957 24156.16 30442.44 0 519994.00 INCOME 957 8.9237200 17.7592404 1.0000000 99.0000000 DISLOC 957 0.2549634 0.4360685 0 1.0000000 TRAIN 957 0.4085684 0.4918262 0 1.0000000 MONTHU 957 3.8787879 8.3599676 0 36.0000000 RATE 957 1.2988506 0.7119194 0 2.0000000 ---------------------------------------------------------------------2) Program/*U:\CLASS\90776\PROGRAMS\HW1P2.SAS performs the tasks in hw 1, problem 2*//* by Rob Greenbaum*//* date 2/8/1999*//* The program creates an ASCII data set containing the Timberwolves attendance data from Lab1, problem 4: u:\class\90776\data\text\twp2.txt*/libname classdat 'u:\class\90776\data';filename twolves 'u:\class\90776\data\text\twp2.txt';/* a, c, d. Bring in the SAS data set, create a new variable, and save the data as an ASCII data set *//* Variables in lab1p4.sd2 are date, attend, total, average */DATA prob2; FILE twolves; /* tells SAS that I want to save an ASCII file to u:\class\90776\data\text\twp2.txt */ set classdat.lab1p4; /* this brings in the SAS data set */avg1000=average/1000; /* create the new variable */PUT date attend total average avg1000; /*tells SAS the names of the variables to save */ RUN;/* c. Print the date and average attendance variables */PROC print; VAR date avg1000; /*tells SAS to print only these 2 variables */RUN;OutputThe SAS System 15:47 Monday, March 8, 1999 5 OBS DATE AVG1000 1 1 16.422 2 2 17.714 3 3 17.860 4 4 17.8723) Program/* The program creates a permanent SAS data set containing the cloud seeding data: u:\class\90776\data\text\cloud.txt */options pageno=1;libname classdat 'u:\class\90776\data';filename cldtxt 'u:\class\90776\data\text\cloud.txt';/* a. Bring in the ascii data and save as u:\class\90776\data\cloud.sd2 */data classdat.cloud; INFILE cldtxt; INPUT PERIOD SEEDED $ SEASON $ TE TW NC SC NWC;RUN;/* b. display contents*/PROC CONTENTS data= classdat.cloud;RUN;/* b. descriptive stats of all variables*/PROC MEANS data = classdat.cloud;RUN;OutputThe SAS System 15:47 Monday, March 8, 1999 1 CONTENTS PROCEDURE Data Set Name: CLASSDAT.CLOUD
View Full Document