Hi,
I have a sample dataset with the following columns. To compare all the columns I want to do comparison with the data step. Values can be empty or string or numeric
data have; informat id v1-v12 $8.; input id v1-v12; cards; 1 1 1 1 3 a b . 4 x . 2 2 2 4 5 h k L L A a 4 6 7 c 3 3 4 5 6 7 3 6 8 8 a w d 4 6 7 2 1 1 2 3 4 5 6 7 s ;
There are data for 12 months.I want to compare them in order.
cats(ifc(v1=v2,'0','1') cats(ifc(v2=v3,'0','1') cats(ifc(v3=v4,'0','1') cats(ifc(v4=v5,'0','1') cats(ifc(v5=v6,'0','1') cats(ifc(v6=v7,'0','1') cats(ifc(v7=v8,'0','1') cats(ifc(v8=v9,'0','1') cats(ifc(v9=v10,'0','1') cats(ifc(v10=v11,'0','1') cats(ifc(v11=v12,'0','1')
At the end, a concatenated string will be formed.
For id = 1 concat_compare='0;0;1;1;1;1;1;1;1;1;0' and
same_count=7 /* I have 3 item for 1, 2 item for 2 and 2 item for missing ,sum(3,2,2) */ not_same_count=5
same_values=1;2; .; /*distinct values, Although it is not the same but more than one / If empty record exists it must be listed */
not_same_values=3;a;b;4;x /*distinct values only have one */
I found a code to find the number of the same on the forum.
data want (drop=i j); set have; array vars $8. v1-v12; same=0; do i=1 to dim(vars)-1; do j=i+1 to dim(vars); same=sum (same, vars(i) eq vars(j)); end; end; run;
But I could not do the others.
I need the following fields on a record-based.
concat_compare same_count not_same_count same_values not_same_values
Is it possible to do this for each record/id?
Best regards
... View more