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
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.
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.