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

Hi,

 

I need to restructure my data set in order to use it as social network data. In the attached file there is the input data and how I want it to be structured (Solution 1 or Solution 2).

 

nw.png

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Assuming I understood what you mean.

 

data have;
input point $ person;
cards;
A 1
A 2
B 1
B 2
B 3
C 2
C 3
;
run;
proc sql;
select a.point,a.person as person1,b.person as person2
 from have as a,have as b
  where a.point=b.point and a.person ne b.person
   order by 2,1;
quit;

View solution in original post

5 REPLIES 5
ballardw
Super User

1) no attached file

2) best to provide existing data in the form of a data step so we have no need to question variable names or types

3) I think you need to describe what is going on in "solution 1". Why is there a 2 A 1 but no 3 C 2 for instance.

 

Is solution 2 a report or a data set? You cannot have a variable named 1, 2 or 3 in a SAS data set so you would have to show what variables you actually want.

ChrisHemedinger
Community Manager

@ballardw and @juliehn - I removed the attachment (XLS) file and replaced with a picture inline -- thought that would be more useful for experts to respond.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Ksharp
Super User

Assuming I understood what you mean.

 

data have;
input point $ person;
cards;
A 1
A 2
B 1
B 2
B 3
C 2
C 3
;
run;
proc sql;
select a.point,a.person as person1,b.person as person2
 from have as a,have as b
  where a.point=b.point and a.person ne b.person
   order by 2,1;
quit;
juliehn
Fluorite | Level 6

It worked and data is organised just like I wanted.Thanks a mil!

TomKari
Onyx | Level 15

I think you'll find either of your preferred structures will turn out to be impractical in practice, as the number of persons and meeting points expands. Here's a solution I did for someone else, which groups the nodes into networks. From there, you should be able to restructure it as needed.

 

Tom

 

data TestData;
	input From To;
	cards;
1 15
1 16
15 16
2 16
2 17
16 17
3 4
4 5
5 6
6 18
7 18
8 19
9 19
10 20
10 19
20 19
11 8
12 21
12 20
12 13
21 20
21 13
20 13
13 22
13 23
22 23
14 23
14 24
23 24
9 25
run;

proc optnet data_links=TestData out_nodes=Networks;
	concomp;
run;

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 906 views
  • 3 likes
  • 5 in conversation