BookmarkSubscribeRSS Feed
ani_89
Obsidian | Level 7

I have a credit card user data in the below mormat.

 

Card_number    Customer_NumberDate_became_memberMemtype
4.67853E+15589121523/15/1994           P
4.67853E+15589121521/1/2000           A
4.67853E+15589121531/9/2001           P
4.67853E+15589121531/7/2002           A
4.67853E+15589121533/4/1993           A
4.67853E+155891215712/23/1995           P
4.67853E+15589121601/17/2000           P
4.67853E+15589121611/26/2000           P
4.67853E+155891216110/27/1995           A
4.67853E+155891216211/5/2002           P
4.67853E+155891216211/9/1993           A
4.67853E+15589121621/26/2002           A

 

 

But in my data the date_became_member is not icorrect order.I want to create a data set like

below.

 

Card_numberCustomer_NumberDate_became_memberMemtype
4678527546403500589121523/15/1994P
4678527546219220589121521/1/2000A
4678527546976100589121533/4/1993P
4678527546503750589121531/9/2001A
4678527546329640589121531/7/2002A
46785275467686605891215712/23/1995P
4678527546294870589121601/17/2000P
46785275468289605891216110/27/1995P
4678527546666830589121611/26/2000A
46785275466983105891216211/9/1993P
4678527546340550589121621/26/2002A
46785275466127505891216211/5/2002A

 

The main logis is that MEMTYPE =P signifies it is a primary customer and it should have minimum 

date of date became member.MEMTYPE=A signifies the add on card of a customer.

 

Please help me to get my desired output.

 

1 REPLY 1
ballardw
Super User

First question is are your dates SAS date values or character? If proc contents shows them with format mmddyy10 or similar then the dates are okay. If not then you likely need to create a SAS date value that will sort correctly.

 

If I understand what you are wanting something like this:

proc sort data= have;
   by Customer_number date_became_member;
run;

data want;
   set have;
   by Customer_number date_became_member;
   if first.customer_number then Memtype='P';
   else Memtype='A';
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 677 views
  • 0 likes
  • 2 in conversation