Question
Using SAS data Suppose the raw data file Examdata1.txt in folder C:Temp contains information of each customer. There are five consecutive rows of records for
Using SAS data
Suppose the raw data file Examdata1.txt in folder C:\\Temp contains information of each customer. There are five consecutive rows of records for each customer in the file. Figure 1a shows a few example records in the raw data file. The description of the fields in each record is shown in Figure 1b. There is no missing value in the records.
Figure 1a: A few example records of Examdata1.txt. The first line in the figure is not part of the raw data records.
1234567890123456789012345678901234567890 |
\"MORGAN GEORGE\" 25/04/2000$13,500 2018Q1 130 2018Q3 100 2019Q1 50 2019Q2 0 STARR ALTON 06/12/1999 $26,000 2017Q3 200 2017Q4 50 2018Q2 75 2018Q3 100 \"YOUNG LAWRENCE\" 03/01/1996 $8,000 2016Q1 60 2016Q2 0 2018Q1 20 2018Q4 30 |
Figure 1b: Description of the fields in each record of Examdata1.txt.
Row | Field description | Column Positions (Start End) | Format |
1 | Customers name | 1 - 20 | Up to 20 characters including embedded blank spaces and text qualifier in the form of a pair of double quotation marks in some records. If text qualifier is present in the field, the first double quotation mark always appears in the first column of the field. |
Date of birth | 21 - 30 | Date in the form of dd/mm/yyyy. | |
Monthly Income | 31 or beyond - vary | Numeric in various length; begins with a $ symbol and contains thousand commas. | |
2-5 | Quarter of specified year | 1 - 6 | Six characters exactly in the form of yyyyQn where yyyy is the year, and n is the quarter (1, 2, 3, or 4) of the year. |
Amount Spent | 8 - vary | Standard numeric in various length. |
You are asked to write a SAS DATA step to create a SAS data set named Sasdata1 in the Work library of SAS. Sasdata1 must contain the following characteristics:
- It contains 1 observation for each customer. Only the 1st, the 2nd, and the 4throw of records of each customer are used to form the observation. Ignore the 3rdand the 5throw of records of each customer.
- Strip off the quotation marks, if present, from the values of Customers name field.
- Store the values of Date of birth field as SAS date values.
- Strip off the dollar symbols and the thousand commas, if present, from the values of Monthly income field.
- Keep only the year value (as a SAS numeric type) in Quarter of specified year field.
A few example observations of Sasdata1 are shown in Figure 1c. Your created Sasdata1 must look exactly as shown, including the name of the variables, the order of the variables, the values of the variables, and the order of the observations.You must create the required SAS data set with one DATA step only. Using any other procedures are prohibited.
Step 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