Hi,
I need some logic to carry out the following requirements if possible please.
My current table (New_Orders) has the following variables
Name
REF
Last Name
Order
Region
Status
TelNo
Login_id
What I need is to create 2 new variables within this table called
'New_Order'
and
'Curr_User'
Requirements
New Variable 'New_Order' = if Login_ID is in table New_Orders and New_Orders_Prev_Month then 'Existing' else 'N/A'
New Variable 'Curr_User' = if Email is in table New_Orders and New_Orders_Prev_Month then '1' else 'N/A'
Thanks
Can you describe your problem with some sample data and what you want the result to look like from that data? Makes it much easier to provide a usable code answer.
What I am trying to understand is how many existing customers do we have (these will be captured within previous months table) that have made a new order vs newly on boarded customers (that won't exist in the previous months table).
Ok. How big is your data?
Repeating what @PeterClemmensen already said: please post data showing what you have and what you expect as result. From the description it seems that you need a simple merge with some logic to mark those customers not already in the previous month table.
I can't see your data, so needless to say, this is untested
data New_Orders_1;
if _N_=1 then do;
declare hash h(dataset:'New_Orders_Prev_Month');
h.definekey('Login_id');
h.definedone();
end;
set New_Orders;
if h.check()=0 then New_Order='Existing';
else New_Order='N/A';
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.