data t1;
input cinfno carte$;
datalines;
1 caba
1 cb
2 cb
3 caba
4 cb
4 caba
5 caba
;
run;
Using data steps write a code to display the number of customers having
carte: CB
Carte: caba
carte : both
data t1;
input cinfno carte$;
datalines;
1 caba
1 cb
2 cb
3 caba
4 cb
4 caba
5 caba
;
run;
/*no of customers having both*/
data w1;
set t1 end=lr;
by cinfno;
if not(first.cinfno and last.cinfno) then f=1;
if last.cinfno and f then no_of_customers_both+1;
if lr;
keep no_of_customers_both;
run;
proc sort data =t1 out=t;
by carte;
run;
data w2;
set t end=lr;
by carte;
if first.carte then numberofcustomers=1;
else numberofcustomers+1;
if last.carte;
run;
Hi @Guptashwe
Note that I've updated the subject line of your question to be more descriptive. Please use a more descriptive subject line in the future. This is to allow other future users to search for a topic and find the relevant answers more easily.
@Guptashwe wrote:
data t1;
input cinfno carte$;
datalines;
1 caba
1 cb
2 cb
3 caba
4 cb
4 caba5 caba
;
run;
Using data steps write a code to display the number of customers having
carte: CB
Carte: caba
carte : both
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.