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

Hi everyone,

 

Here is a sample of my data.

The OBS is a unique individual.

Each column is a state that they have visited. 1=yes, 0=no

 

I'd like to to figure out the various combinations of states.

 

For example: OBS 1 and 7  has visited NewYork and Texas so NewYorkTexas would be 2

 

I'd like to do that for all possible combinations. Any suggestion as to how to begin?

 

 

OBSNewYorkCaliforniaTexasNewJerseyWashington
110100
201100
300101
411001
500001
601100
710101
811011
911100
101101

1

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

An easy way would be to string together all the flags:

 

all_locations = cat(NewYork, California, Texas, NewJersey, Washington);

 

You need to preserve this logic, so you know which position represents which state.

 

Then count:

 

proc freq data=have;

tables all_locations;

run;

 

 

View solution in original post

4 REPLIES 4
Astounding
PROC Star

An easy way would be to string together all the flags:

 

all_locations = cat(NewYork, California, Texas, NewJersey, Washington);

 

You need to preserve this logic, so you know which position represents which state.

 

Then count:

 

proc freq data=have;

tables all_locations;

run;

 

 

hwangnyc
Quartz | Level 8

That was a astounding answer! THANK YOU!

Andygray
Quartz | Level 8

Hi @hwangnyc Can you post the output for the sample you provided for the benefit of the wider audience. Thank you! 

Reeza
Super User
Run PROC CORR with the SSCP MATRIX.
https://gist.github.com/statgeek/a5184a4e1678d81e2643#file-sas_distance_matrix-sas

This will give you a matrix of the trips.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1089 views
  • 0 likes
  • 4 in conversation