lab1_exercises

docx

School

University of Southern California *

*We aren’t endorsed by this school

Course

MISC

Subject

Statistics

Date

Apr 3, 2024

Type

docx

Pages

7

Uploaded by MegaElkPerson49

Report
Lab #1 Exercises All ASCII datasets referenced below are located in the Lab Datasets folder in the Course Resources section of Canvas. Please provide all relevant code and output to receive full credit for the lab. 1) Answer the following problems from Exercises and Project for The Little SAS Book: Chapter 6: Questions Q2. B. BY Q4. C. 4 Q6. C, A Note Q14. C. IN= Q20. DATA class1; MERGE one class2; BY stuname stuid finalscore; PROC PRINT data= classwhole; RUN; Proc Means Data = classwhole; Var; Run; Q22. If one data set contains data for different months. It would be better to stack the data set on each other because the data is in the order of months Q26. The FIRST.Gender command will display a value of 1 the first time that SAS reads the value of either gender and will display a value of 0 every other time. While the FIRST.Height command will tell SAS to display a value of 1 for each unique value of height unique means the first time SAS reads a new value for the variable height. Such as seen below: Name JoAnn F 64 1 1 Jane F 66 0 1 Joyce F 68 0 1 David M 69 1 1 Stan M 70 0 1 Jim M 71 0 1 Bob M 71 0 0 2) You have a file containing gymnastics scores for boys and girls as follows: ID Gender Age Vault Floor P_BAR 3 M 8 7.5 7.2 6.5 5 F 14 7.9 8.2 6.8 2 F 10 5.6 5.7 5.8 7 M 9 5.4 5.9 6.1 6 F 15 8.2 8.2 7.9
The data are stored in a file called ‘gym.dat’. Read the data from this source ( not using datalines). (a) Create a SAS data set called GYM from these data. data gym; infile "Z:\OneDrive\Documents\sas\GYM.DAT" ; input id @ 4 gender$ age vault floor P_BAR; Run ; (b) Use PROC CONTENTS and PRINT to view the database. data gym; infile "Z:\OneDrive\Documents\sas\GYM.DAT" ; input id @ 4 gender$ age vault floor P_BAR; Run ; proc contents data = gym; run ; proc print data= gym ; run; (c) Create a subset of these data from males only. Call it MALE_GYM. data male_gym; infile "Z:\OneDrive\Documents\sas\GYM.DAT" ; input id @ 4 gender$ age vault floor P_BAR; if gender= 'm' ; run ; (d) Create another subset of GYM for all females greater than or equal to 10 years of age. Call it OLDER_F. data older_f; infile "Z:\OneDrive\Documents\sas\GYM.DAT" ; input id @ 4 gender $ age vault floor P_Bar; if _5_ <= 10 ;
run ; 3) You have two data files, one from the year 1996 and the other from the year 1997, as follows: File for 1996 File for 1997 ID Height Weight ID Height Weight 2 68 155 7 72 202 1 63 102 5 78 220 4 61 111 3 66 105 The data are stored in files called ‘data96.dat’ and ‘data97.dat’. Create a SAS data set from each file (call them YEAR1996 and YEAR1997, respectively.) Use PROC CONTENTS and PRINT to view the database. Combine the data from each data set into a single file (call it BOTH). data year1996; infile "Z:\OneDrive\Documents\sas\DATA96.DAT" ; input id height weight; run ; data year1997; infile "Z:\OneDrive\Documents\sas\DATA97.DAT" ; input id height weight; run ; proc contents data = year1996; run ; proc print data = year1996; run ; proc contents data = year1997; run ; proc print data = year1997; run ; proc sort data = year1996; by id; run ; proc sort data = year1997; by id;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
run ; data year1996year1997; merge year1996 year1997; by id; run ; 4) You have a separate file on the children in problem 2). This file contains ID numbers, income ranges, and the parents’ last names as follows: ID Income L_Name 3 A Klein 7 B Cesar 8 A Solanchick 1 B Warlock 5 A Cassidy 2 B Volick The data are stored in the file ‘income.dat’. Note that there are ID’s for which there is no GYM data and vice versa. First, create a SAS data set called MONEY from the data above. Use PROC CONTENTS and PRINT to view the database. Next, merge the two data sets (call the merged data set GYMMONEY). Make the database GYMMONEY a permanent SAS database stored in your directory. Make sure to include everyone in the database, and note who has missing values. Next, print out a list showing ID, last name, gender, and age. Have this list in ID order. data money; infile "Z:\OneDrive\Documents\sas\INCOME.DAT" ; input id income L_Name; run ; proc contents data = money; run ; proc print data = money;
run; ; data gymmoney; merge money gym; run ; libname gymmoney "Z\OneDrive" ; data gymmoneyy; set gymmoney;
run ; 5) Combine the GYMMONEY data set from problem 4) with the data set BOTH from problem 3). Put the resulting data in your permanent SAS database GYMMONEY. Use PROC CONTENTS and PRINT to view the database. 6) You have a financial plan based on income range and gender. Using the GYMMONEY data set from problem 5), create a new data set, which contains all the data from GYMMONEY along with the correct final plan based on the table below: Income Range Gender Financial Plan A M W A F X B M Y B F Z The data are stored in the file ‘finance.dat’. Read the data into a temporary SAS database called FINANCE, and then store the final combined data set in your permanent SAS database GYMMONEY. data gymmoney; merge gymoney finance; by income gender; run ;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help