Hello
For each customer ID there is information of existence of 5 files (binary variables minus1,minus2,minus3,minus4,minus5).
There is also information of fist location customer appear.
I want to create want data set with following information:
For each customer ID:
Customer_First_Location (This column already exist in have data set)
First_File_Location (New column need to create)
status(New column need to create)
IF Customer_First_Location =First_File_Location then it is ok.
IF Customer_First_Location is after First_File_Location then it is not_ok
What is the way to create want data set?
data have;
input ID minus1 minus2 minus3 minus4 minus5 Customer_First_Location;
cards;
1 1 1 1 1 1 -1
2 0 1 0 0 1 -5
3 0 0 0 1 0 -4
4 0 0 0 0 1 .
;
Run;
Data want;
input ID Customer_First_Location First_File_Location status;
cards;
1 -1 -1 OK
2 -5 -2 Not_OK
3 -4 -4 OK
4 . -5 Not_OK
;
Run;
I took a guess at how to derive first_file_location:
data want ;
set have ;
length Status $8 ;
First_File_Location=whichn(1,of minus1-minus5) * -1 ;
if First_File_Location=Customer_First_Location then status='OK' ;
else status='Not_OK' ;
run ;
proc print ;
run ;
From your description:
>First_File_Location (New column need to create)
Nothing in this code indicates how that value is derived. Please explain how you are generating the value for First_File_Location.
You have not explained how First_File_Location is created.
I took a guess at how to derive first_file_location:
data want ;
set have ;
length Status $8 ;
First_File_Location=whichn(1,of minus1-minus5) * -1 ;
if First_File_Location=Customer_First_Location then status='OK' ;
else status='Not_OK' ;
run ;
proc print ;
run ;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.