Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please USE SAS This assignment will give you practice reading data into SAS from several types of formats. There are 3 parts to the assignment.
Please USE SAS
This assignment will give you practice reading data into SAS from several types of formats. There are 3 parts to the assignment. You may create one program by appending the code for each part or create separate programs for each part. You may find it helpful to write the program on a piece of paper before you work on the computer. It is very important to look at the log after running your program each time to make sure there are no errors.
students.xlsx F, 23. 5, 15, MN F,21., 15, WI F,22,S, 09, MN F, 35, M, 02, MN F, 22.M, 13, MN F, 25,9,13, WI M, 20.5, 13, MN M, 26.M, 15, WI M.2705,MN M.S,14,IA M, 21, 5, 14, MN M, 29.M, 15, MN The variables are gender (F or M), age, marital status (S or M), number of credits taken, and state of residence (MN, WI, or IA). Note there is missing data in rows 9 and 10. Write a SAS program that reads the data from students.xlsx and creates a SAS dataset called class. Name the variables gender, age, marstat, credits, and state. The variables gender, marstat, and state are character variables, age and credits are numeric variables. The first two statements will include the following: PROC IMPORT DATAFILE='C:/falderpath/students.xlsx' OUT=work clans DBMS=x13x REPLACE; GETNAMES=YES; RUN; Display the list of variables on the dataset using PROC CONTENTS. Also display the values of the variables using PROC PRINT. Run the program, making sure the data is read in correctly. 2. The data file bp.txt is a tab delimited file containing blood pressure and other data on 100 patients. The variables in order are the patient ID, clinical center, age, sex, diastolic BP at baseline, 6-months, and 12-months (3 variables), and systolic BP at baseline, 6-months, and 12- months (3 variables). a. Write a SAS program that reads the data from bp.txt and creates a SAS dataset called bp1 Name the variables ptid, clinic, age, sex, dbpbl. dbp6, dbp12. sbpbl, sbp6, and sbp12. Variables ptid and clinic are character variables; all other variables are numeric. Display the list of variables on the dataset using PROC CONTENTS. Also, display the values of the variables using PROC PRINT to verify the variables are read-in correctly *** Note: Since the first row of the file contains column headings you will need to use the FIRSTOBS=2 option on the INFILE statement to skip over this row. b. Instead of using a data-step, use PROC IMPORT to read the file creating a dataset called bp2. Run PROC CONTENTS and PROC PRINT as before on this dataset. Compare the PROC CONTENTS from part a with the PROC CONTENTS from part b. What is the length of the variable clinic in dataset bpl compared to dataset bp2? students.xlsx F, 23. 5, 15, MN F,21., 15, WI F,22,S, 09, MN F, 35, M, 02, MN F, 22.M, 13, MN F, 25,9,13, WI M, 20.5, 13, MN M, 26.M, 15, WI M.2705,MN M.S,14,IA M, 21, 5, 14, MN M, 29.M, 15, MN The variables are gender (F or M), age, marital status (S or M), number of credits taken, and state of residence (MN, WI, or IA). Note there is missing data in rows 9 and 10. Write a SAS program that reads the data from students.xlsx and creates a SAS dataset called class. Name the variables gender, age, marstat, credits, and state. The variables gender, marstat, and state are character variables, age and credits are numeric variables. The first two statements will include the following: PROC IMPORT DATAFILE='C:/falderpath/students.xlsx' OUT=work clans DBMS=x13x REPLACE; GETNAMES=YES; RUN; Display the list of variables on the dataset using PROC CONTENTS. Also display the values of the variables using PROC PRINT. Run the program, making sure the data is read in correctly. 2. The data file bp.txt is a tab delimited file containing blood pressure and other data on 100 patients. The variables in order are the patient ID, clinical center, age, sex, diastolic BP at baseline, 6-months, and 12-months (3 variables), and systolic BP at baseline, 6-months, and 12- months (3 variables). a. Write a SAS program that reads the data from bp.txt and creates a SAS dataset called bp1 Name the variables ptid, clinic, age, sex, dbpbl. dbp6, dbp12. sbpbl, sbp6, and sbp12. Variables ptid and clinic are character variables; all other variables are numeric. Display the list of variables on the dataset using PROC CONTENTS. Also, display the values of the variables using PROC PRINT to verify the variables are read-in correctly *** Note: Since the first row of the file contains column headings you will need to use the FIRSTOBS=2 option on the INFILE statement to skip over this row. b. Instead of using a data-step, use PROC IMPORT to read the file creating a dataset called bp2. Run PROC CONTENTS and PROC PRINT as before on this dataset. Compare the PROC CONTENTS from part a with the PROC CONTENTS from part b. What is the length of the variable clinic in dataset bpl compared to dataset bp2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started