BookmarkSubscribeRSS Feed
JI_22
Calcite | Level 5

Hi,

Would be glad if someone could help me with my problem.

I want to create one more column where I flag customers from other existing columns.

Can somebody please help me with that code?

 

In column A I have "MOTHERCUST_ID", in column B I have "CUST_ID" and in column C I have "ORG_NR".


The code I want will give me:

If one "MOTHERCUST_ID" (column A) have one or more "CUST_ID" (column B), and all have the same "ORG_NR" (column C) as the mother - they should all get "TRUE" in column D.

If one "MOTHERCUST_ID" (column A) have more than one "CUST_ID" (column B), and one or all have different "ORG_NR" (column C) than the mother - they should all get "FALSE" in column D. -Even if one of the customer have the same orgnr and the rest is wrong, they should all get "FALSE".

 

*See how I want the result in new column in the attach file, marked with different colors.
Black is customer who have only one row per customer
Red is group-customer who have more than one customer connected, but all with same org-number.
Green is group-customer who have more than one customer connected, where one or all org-number is different than the mother.

 

JI


Capture.JPG
4 REPLIES 4
Patrick
Opal | Level 21

@JI_22 

It's great that you've posted the desired output.

Please provide also sample source data (a SAS data step creating such data) so we can post working and tested code. Posting such code is much simpler and clearer than trying to explain to you verbally what needs to be done.

 

 

JI_22
Calcite | Level 5

@Patrick

I´m not sure what you mean here?

I thougt maybe that I could write some kind of code or an expression that should give me what I needed.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

We cannot see what your data looks like, therefore need to re-create it, follow this post:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

 

Patrick
Opal | Level 21

@JI_22

The only thing I'm asking for is that you post a SAS data step which creates for us sample data.

Something like:

data have;
  infile datalines dsd dlm=',' truncover;
  input mothercust_id cust_id org_nr;
  datalines;
1,11,1234
2,22,1235

...all the other observations as shown in your screen shot ; run;

If you've got already a SAS data set then you can also use the link @RW9 posted to create such a SAS data step

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 807 views
  • 0 likes
  • 3 in conversation