Desktop productivity for business analysts and programmers

SAS query

Reply
New Contributor
Posts: 2

SAS query

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
Respected Advisor
Posts: 4,130

Re: SAS query

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

 

 

New Contributor
Posts: 2

Re: SAS query

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

Super User
Super User
Posts: 7,668

Re: SAS query

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

 

 

Respected Advisor
Posts: 4,130

Re: SAS query

[ Edited ]

@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

Ask a Question
Discussion stats
  • 4 replies
  • 118 views
  • 0 likes
  • 3 in conversation