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.
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
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!
WANT UNIQUE TRANSACTION MONTH ?
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.
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???
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 :
Bill | Txn_Date | newcin |
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 |
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,
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;
Dear KurtBremser,
Excellent.Thank you very much.
Regards,
Dhruva.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.