BookmarkSubscribeRSS Feed
alexjaco
Calcite | Level 5

Hello,

 

Is there a way to report on all unique values within a subset of data? For instance looking within the test1 set of data and comparing test1.1 to test1.2 to find that the unique value is 123.

 

Test1Test1.1123
Test1Test1.1124
Test1Test1.1125
Test1Test1.1521
Test1Test1.1324
Test1Test1.2125
Test1Test1.2521
Test1Test1.2124
Test1Test1.2324
4 REPLIES 4
Reeza
Super User

Yes, but it depends on how you define unique and what do you want as an output. 

What do you want as the output?

 

 

alexjaco
Calcite | Level 5

Unique value is anything that appears in row three for Test 1.1 that doesn't appear in row three for test 1.2. Output should be the entire row.  

 

There will be other rows such as

 

Test2Test2.1123
Test2Test2.2124

 

ballardw
Super User

Pretty vague example of desired output.

I am guessing that something like this might get you started;

proc freq data=have noprint;
  tables var1*var2*var3 /missing list out=work.unique(where=(count=1));
run;

Where you place the variables whose combination of "uniqueness" on the tables statement as above, use as man * as you need.

 

Inclusion of the missing option depends on whether you want to count combinations with one or more missing values as a unique combination.

 

If there are more than one data sets involved, which is not actually very clear, then more details are needed and likely some actual example data in the form of data steps to create the example data sets.

Astounding
PROC Star

You give us three columns of data, so I'm going to imagine that the variable names are v1 v2 and v3. 

 

proc sort data=have;

by v1 v3;

run;

 

data want;

merge have (in=in1 where=(v2='Test1.1'))

have (in=in2 where=(v2='Test1.2'));

by v1 v3;

if in1=0 or in2=0;

run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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