BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dhruvakumar
Obsidian | Level 7

Dear all,

I stuck in one issue, I have dataset which is having 3 months, but I need to select customer data who have different  transaction data.

 

Example

IF First month 60 and second month 60 and third month 60.....> Then to be delete

IF First month 60 and second month 50 and third month 60.....> Then to be delete

IF First month 60 and second month 50 and third month 40.....> Then to be Include.

 

Please help on this issue.

1 ACCEPTED SOLUTION

Accepted Solutions
dhruvakumar
Obsidian | Level 7

Dear KurtBremser,

 

Excellent.Thank you very much.

 

 

Regards,

Dhruva.

View solution in original post

10 REPLIES 10
TarunKumar
Pyrite | Level 9

Hi Dhruv,

 

use intck function to calculated no of days or no of month between tow  transaction date.

 

no_of_day = intck("days",'01jan18'd,'01apr18'd) ---> will show the no of days

 

no_of_day = intck("MONTH",'01jan18'd,'01apr18'd)  ----> will show the no of month

 

dhruvakumar
Obsidian | Level 7

Hi Tarun,

 

thanks for reply. Here my requirement is not to delete months. In the above example 60 is not number of days, it transaction amount.

In the first instance all 3 months have 60 so ,it will not be select, same as second which 60 is repeated in twice.. so it would be not select.

Last instance.. it have three different transaction amount so it would be include.

 

Thanks!

TarunKumar
Pyrite | Level 9

WANT UNIQUE TRANSACTION MONTH ?

Kurt_Bremser
Super User

It is always a VERY GOOD IDEA to supply example data that illustrates the issue and which can be used for testing. The proper method for this is posting a data step with datalines. A macro that does the conversion of a dataset to a data step can be found here, and the proper method for posting code so that the formatting is preserved can be found here.

ballardw
Super User

Provide example input data.

 

Provide example desired result. Data is best provided in the form of data steps so we know variable names and types.

 

Post question requirements in terms of those named variables in your data set.

You may know what

IF First month 60 and second month 60 and third month 60.....> 

means but without data, variables and explanations of how you determine a value is first month and what ever the heck 60 is we can't help much. And are you interested in exactly 60, greater than 60, less than 60, greater than or equal to 60 or less than or equal to 60???

 

dhruvakumar
Obsidian | Level 7

Dear All,

 

Thank you.As mentioned if transaction data :

 

IF First month 60 and second month 60 and third month 60.... then it should be not select.

 

Only the transaction if First month 60 and second month 50 and third month 40... will be select from dataset. Means transaction data should be distinct .. they only data should be select in the query.

Example :

BillTxn_Datenewcin
6004/01/2018EMP1001
6004/02/2018EMP1001
6004/03/2018EMP1001
4004/01/2018EMP1002
5004/02/2018EMP1002
3004/03/2018EMP1002


In the above example only EMP1002  should be select,because  it is having distinct bill amount 30,40,50.

 

The other EMP1002   should not select, because it is having the same bill amount 60,60,60

 

Here my requirement is need to select only EMP1002 records only.

 

Thanks,

Dhruva,

 

 

Kurt_Bremser
Super User

Here is a quick example of what we mean by "post datasets in a data step":

data have;
input bill txn_date :mmddyy10. newcin $;
cards;
60 04/01/2018 EMP1001
60 04/02/2018 EMP1001
60 04/03/2018 EMP1001
40 04/01/2018 EMP1002
50 04/02/2018 EMP1002
30 04/03/2018 EMP1002
;
run;

Please follow this example in the future, as it makes creating and testing code that much easier.

 

A solution SQL looks like this:

proc sql;
select * from have
where newcin in (
  select newcin
  from have
  group by newcin
  having count(distinct bill) > 1
)
;
quit;
dhruvakumar
Obsidian | Level 7

Dear KurtBremser,

 

Excellent.Thank you very much.

 

 

Regards,

Dhruva.

Patrick
Opal | Level 21

@dhruvakumar

If @Kurt_Bremser answer is the solution for you then please mark it as solution. This is your way to say "thank you" and it also shows your question as answered on the overview page.

dhruvakumar
Obsidian | Level 7
Hi Patrick,

Thank you for advise.Done.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 10 replies
  • 1772 views
  • 1 like
  • 5 in conversation