BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi



data cus_mon;
input cus mon$ emi;
cards;
1 jan 20
2 jan 10
3 jan 20
1 feb 20
2 feb 20
3 feb 10
1 mar 20
2 mar 20
3 mar 20
run;

i want the no of customers paying the emi same amount in the months jan,feb and mar in this Dataset cusomer 1 is paying the same emi in all the three months like this i want the count of .No of customers paying the same amount in all the three months .

I am having 30,000 obs i sholud find this from that obs
5 REPLIES 5
Peter_C
Rhodochrosite | Level 12
sql or data step?
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
One suggestion is that you appear to be working with "character string" date-related data values (without a year supplied in the input) -- convert these to SAS numeric DATE type variables using the INPUT function in a SAS assignment statement - a DATA step approach likely, possibly assigning the current year using the YEAR( TODAY() ) functions. Then you can use the MONTH() if you need to reference one or more months as a logical group in your IF / THEN variable assignment logic.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS support http://support.sas.com/ website has a wealth of SAS-hosted product documentation and also technical / conference contributed papers on these type of topics - some links pasted below for your reference and use:

Scott Barry
SBBWorks, Inc.

Working with Dates in the SAS System

http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm


How the DATA Step Identifies BY Groups

Processing Observations in a BY Group

http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000761931.htm



A Hands-On Introduction to SAS® DATA Step Programming
Debbie Buck, D. B. & P. Associates, Houston, TX
http://www2.sas.com/proceedings/sugi30/134-30.pdf


SAS 9.2 DOC - Data Step Processing:
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001281588.htm

Processing a DATA Step: A Walkthrough
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000961108.htm
deleted_user
Not applicable
In DATA step
Peter_C
Rhodochrosite | Level 12
since the chain is over only 3 months, it seems OK just to merge the 3 separate months and, if the amounts (emi) are the same, create a counter[pre]data counting( keep= cus emi1 ) ;
merge cus_mon( in=jan rename=( mon= mon1 emi= emi1 ) where=( mon1= 'jan'))
cus_mon( in=feb rename=( mon= mon2 emi= emi2 ) where=( mon2= 'feb'))
cus_mon( in=mar rename=( mon= mon3 emi= emi3 ) where=( mon3= 'mar') )
;
by cus ;
if jan and feb and mar and
emi1= emi2 and emi2=emi3 then output ;
run ;
proc print ;
run ; [/pre]
The count is the number of observations output to table COUNTING.

PeterC

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 631 views
  • 0 likes
  • 3 in conversation