I have a credit card user data in the below mormat.
Card_number | Customer_Number | Date_became_member | Memtype |
4.67853E+15 | 58912152 | 3/15/1994 | P |
4.67853E+15 | 58912152 | 1/1/2000 | A |
4.67853E+15 | 58912153 | 1/9/2001 | P |
4.67853E+15 | 58912153 | 1/7/2002 | A |
4.67853E+15 | 58912153 | 3/4/1993 | A |
4.67853E+15 | 58912157 | 12/23/1995 | P |
4.67853E+15 | 58912160 | 1/17/2000 | P |
4.67853E+15 | 58912161 | 1/26/2000 | P |
4.67853E+15 | 58912161 | 10/27/1995 | A |
4.67853E+15 | 58912162 | 11/5/2002 | P |
4.67853E+15 | 58912162 | 11/9/1993 | A |
4.67853E+15 | 58912162 | 1/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_number | Customer_Number | Date_became_member | Memtype |
4678527546403500 | 58912152 | 3/15/1994 | P |
4678527546219220 | 58912152 | 1/1/2000 | A |
4678527546976100 | 58912153 | 3/4/1993 | P |
4678527546503750 | 58912153 | 1/9/2001 | A |
4678527546329640 | 58912153 | 1/7/2002 | A |
4678527546768660 | 58912157 | 12/23/1995 | P |
4678527546294870 | 58912160 | 1/17/2000 | P |
4678527546828960 | 58912161 | 10/27/1995 | P |
4678527546666830 | 58912161 | 1/26/2000 | A |
4678527546698310 | 58912162 | 11/9/1993 | P |
4678527546340550 | 58912162 | 1/26/2002 | A |
4678527546612750 | 58912162 | 11/5/2002 | A |
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.
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.