Task 2:
The data set asign2_customers.sas7bdat contains the details (city of residence, gender,
customer ID, date of birth (DOB), and enrollment date (EnrolDate) of 49,999 registered
customers. Each record has the following variables:
Variable Name Description
CustID Customer’s identity.
City Customer’s city of residence
Gender Gender of the customer (3 levels plus missing values, length of 6
bytes)
DOB Customer’s date of birth (in SAS date values)
EnrolDate Customer’s enrollment date (in SAS date values)
Create a new SAS data set that contains the following characteristics:
• Name the new data set Customers_New and keep it in the SAS library created in Task 1.
• Replace all Gender values (including missing ones if any), except the ‘Male’ and
the ’Female' values, with ‘Unknown’. Name the variable containing the new gender
values as Gender.
• Show each customer's age in full years on 31 Jul 2022 inclusive. For example, if a
customer was born on 1 August 1998, then the customer’s age is 23. Name the variable
containing the computed age value as Age.
• Show each customer’s tenure in the number of days between the customer’s enrollment
date and 31 Jul 2022 inclusive. For example, if a customer was enrolled on 29 Jun 2022,
the customer’s tenure is 3 days. Name the variable containing the tenure values as
Tenure.
• Only these variables are contained in Customers_New: City of residence, customer’s
identity, date of birth, enrollment date, gender, age, and length of tenure
There is some of raw data provided :
City Gender CustID DOB EnrolDate
1 Seatle MFMF 10292 10/15/1964 08/17/2017
2 Seatle MFMF 47965 02/12/1967 08/16/2017
3 New York Female 35046 05/19/1961 08/14/2017
4 Chicago Male 49234 01/08/1986 08/13/2017
5 Seatle 42466 06/06/1979 08/13/2017
6 Seatle Male 38316 03/11/1949 08/13/2017
7 Seatle MFMF 33719 08/22/2012 08/12/2017
8 Seatle Female 34072 10/18/1945 08/12/2017
9 Los Angeles Male 46769 10/11/1952 08/12/2017
10 Chicago Male 46247 06/20/2000 08/11/2017
Since this is your homework, let us see what you have done so far. Post your code in a window opened with the "little running man" button.
Providing usable example data (in text form, ideally as DATA step with DATALINES) will give people something to play around and get you answers more quickly. Do not post pictures of code or data.
What errors? Please show us the log, the ENTIRE log for this code, not selected parts, not just the error messages.
Please copy the log as text and paste it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.
this is what my code's output which is not what i want
This is what i want for my answer.
I dont know which part of my code is wrong.
Post the log by copy/pasting the text into a window opened with this button:
(the "little running man" I mentioned earlier is the one right next to it)
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.