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.
Test1 | Test1.1 | 123 |
Test1 | Test1.1 | 124 |
Test1 | Test1.1 | 125 |
Test1 | Test1.1 | 521 |
Test1 | Test1.1 | 324 |
Test1 | Test1.2 | 125 |
Test1 | Test1.2 | 521 |
Test1 | Test1.2 | 124 |
Test1 | Test1.2 | 324 |
Yes, but it depends on how you define unique and what do you want as an output.
What do you want as the output?
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
Test2 | Test2.1 | 123 |
Test2 | Test2.2 | 124 |
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.
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;
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!
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.