BookmarkSubscribeRSS Feed
buckeyefisher
Obsidian | Level 7

I want to count diadic relationship between alliance partners per year. 

 

Data have;

 

No                 Principal Firm         Partner Firm              Year 

1                           a                           b                            1991

2                           b                           c                            1991

3                           a                           x                            1992

4                           a                           b                            1992

5                           x                           a                            1993

6                           x                           z                            1994

7                           c                           b                            1995

8                           b                           a                            1996

 

Data Want;

 

No                 Principal Firm         Partner Firm               Year                      Alliance History Count (Cumulative)

1                           a                           b                            1991                                 1

2                           b                           c                            1991                                 1

3                           a                           x                            1992                                 1

4                           a                           b                            1992                                 2

5                           x                           a                            1993                                 2 

6                           x                           z                            1994                                 1  

7                           c                           b                            1995                                 2 

8                           b                           a                            1996                                 3

 

(Alliance between 'a' -  'b' and between 'b' -'a' should be treated as same) 

 

I tried Proc SQL distinc, but just gives unique relationships. I need count at the diadic relationship level 

 

Thanks,

 

 

 

2 REPLIES 2
Shmuel
Garnet | Level 18

You can create an intermediate variable sort_key by:

     if  principal gt partner

         then sort_key = partner || principal;

         else sort_key =  principal || partner;

 

then run your sql counting group by sort_key.

buckeyefisher
Obsidian | Level 7

Shumel,

 

Although I am yet to verify all possible combinations, initial results are promising. 

 

Thanks,

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 902 views
  • 0 likes
  • 2 in conversation