BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wizkid2050
Fluorite | Level 6

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

View solution in original post

6 REPLIES 6
LinusH
Tourmaline | Level 20

What could possibly be the real business rule behind this operation?

Data never sleeps
Astounding
PROC Star

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;

wizkid2050
Fluorite | Level 6

thanks buddy need this for some project which involves a concept of this.

DeepakSwain
Pyrite | Level 9

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

Swain
Astounding
PROC Star

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.

DeepakSwain
Pyrite | Level 9

Hi Astounding,

I was actually looking for an approaching other than using multiple sets statement. 

 

Regards,

Deepak

Swain

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!

How to Concatenate Values

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.

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
  • 6 replies
  • 1216 views
  • 2 likes
  • 4 in conversation