Hi, what is the most efficient way to grab each unique value from FieldABC for every person listed(i.e. AB and then CD and then EF then GH, etc without duplicates). And then either do option 1 or option 2 as follows:
Option1: Set up a macro to go through each of those unique values to produce a proc freq between FieldABC and FieldXYZ to see where there are matches.
Option2: Do a proc freq displaying all the unique values from FieldABC vs FieldXYZ to see where there are matches.
The table set up looks like this:
Person FieldABC FieldXYZ
PersonA AB CD;EF
PersonB CD;EF;GH EF;GH
PersonC AB;EF AB;
PersonD CD EF;GH
Result would look something like this:
AB CD EF GH
AB 1 0 0 0
CD 0 0 0 0
EF 0 0 1 0
GH 0 0 0 1
Or results could be something like this:
For value ‘AB’
Field XYZ
FieldABC 1
For value ‘EF’
Field XYZ
FieldABC 1
Normalize the data and then just count.
data tall;
set have;
do index=1 to countw(fieldabc,';');
word = scan(fieldabc,index,';');
output;
end;
do index=1 to countw(fieldxyz,';');
word = scan(fieldxyz,index,';');
output;
end;
keep person word;
run;
proc freq ;
tables person*word / noprint out=counts;
run;
Normalize the data and then just count.
data tall;
set have;
do index=1 to countw(fieldabc,';');
word = scan(fieldabc,index,';');
output;
end;
do index=1 to countw(fieldxyz,';');
word = scan(fieldxyz,index,';');
output;
end;
keep person word;
run;
proc freq ;
tables person*word / noprint out=counts;
run;
Thanks!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: