BookmarkSubscribeRSS Feed
KC_16
Fluorite | Level 6

Hi,

 

I need some logic to carry out the following requirements if possible please. 

 

My current table (New_Orders) has the following variables

 

Email

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

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

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.

KC_16
Fluorite | Level 6

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).

 

 

andreas_lds
Jade | Level 19

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.

PeterClemmensen
Tourmaline | Level 20

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 517 views
  • 0 likes
  • 3 in conversation