BookmarkSubscribeRSS Feed
Juicety
Calcite | Level 5

Juicety_0-1701698557798.pngTask 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

 

6 REPLIES 6
Kurt_Bremser
Super User

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.

Juicety
Calcite | Level 5
This is what i write but error anyways :

libname mysaslib '~/raw data/HW2';
proc format;
value $gender 'Male' ='Male' 'Female'='Female'
'OTHER' 'Unknown';
run;

data Customers_New;
SET asign2_customers;
format gender $gender. ;
format DOB EnrolDate MMDDYY10. ;
Age = INTCK('YEAR', DOB, '31JUL2022'd,'c');
Tenure = INTCK('DAY', EnrolDate, '31JUL2022'd,'c');
KEEP City CustID DOB EnrolDate Gender Age Tenure;
RUN;
proc print data=mysaslib.asign2_customers (obs=10) noobs;
run;
PaigeMiller
Diamond | Level 26

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.

PaigeMiller_0-1699900743276.png

--
Paige Miller
Juicety
Calcite | Level 5

Juicety_0-1701701465551.png 

this is what my code's output which is not what i want

 

Juicety
Calcite | Level 5

Juicety_0-1701701562612.png

This is what i want for my answer.

I dont know which part of my code is wrong.

 

Kurt_Bremser
Super User

Post the log by copy/pasting the text into a window opened with this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

(the "little running man" I mentioned earlier is the one right next to it)

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 903 views
  • 0 likes
  • 3 in conversation