data test;
input accounts;
datalines;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;
run;
data test2;
input managers$;
datalines;
a
b
c
;
run;
i have these two data sets i want an output of
1 a
2 b
3 c
4 a
5 b
6 c
7 a
8 b
9 c
10 a
11 b
12 c
13 a
14 b
15 c
plz help me with any logic if possible.
While I agree with the sentiment ... why would you want to ... it's not that lengthy.
data want;
set test;
recno = mod(_n_, 3);
if recno=0 then recno=3;
set test2 point=recno;
drop recno;
run;
What could possibly be the real business rule behind this operation?
While I agree with the sentiment ... why would you want to ... it's not that lengthy.
data want;
set test;
recno = mod(_n_, 3);
if recno=0 then recno=3;
set test2 point=recno;
drop recno;
run;
thanks buddy need this for some project which involves a concept of this.
Hi Astounding,
Thanks for providing us an excellent example of use of multiple set statments for combining datasets having many to many relationship. is there any alternative way? Just curious to know to increase the knowledge base.
Regards,
Deepak
Well, I suppose you could get the same observations, but in a different order, this way:
data want;
set test2;
do _i_=_n_ to _nobs_ by 3;
if _i_ <= _nobs_ then do;
set test point=_i_ nobs=_nobs_;
output;
end;
end;
run;
It's untested code, but looks like it should work.
Hi Astounding,
I was actually looking for an approaching other than using multiple sets statement.
Regards,
Deepak
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.
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.