BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

I would like to know if i can find a way to find the the variables with different vales.  In my data set there are duplicates by 'id' variable vales but other variables values are different. I used proc sort data=one out=two nodupkey;by _all_;run;   With this step one of the duplicate for id=3 removed.  Now I need to know which variables have different values for other subjects. My data set has close to 200 variables. Please suggest. Thank you  

 

 

data one;
input id a $ b $ c $ d e;
datalines;
1 a b c 1 2
1 a b c 1 3
2 b b c 1 2
2 c b c 1 3
3 a b c 1 2
3 a b c 1 2
;

3 REPLIES 3
PGStats
Opal | Level 21

What should the output be for your example data?

PG
knveraraju91
Barite | Level 11

Thank you very much for your time.  

 

My question was, the data set that i am working is subject level data set which should have only one record for 'id'.  In my output there should be only three records. But when i ran 'proc sort data=one out=two nodupkey;by _all_;run; ' i am able to remove only one record which is for id=3.   Now i need to find which variables have different values for id=1 and id=2. In the below example, for id=1, the variable 'e' has different values and for id=2, the variable 'a' and 'e' has different values. So i want to output something like below so i can quickly see which variables have different values

 

output needed

data want;

id     a               e

1                      2,3

2     b,c            2,3

  

 

data one;
input id a $ b $ c $ d e;
datalines;
1 a b c 1 2
1 a b c 1 3
2 b b c 1 2
2 c b c 1 3
3 a b c 1 2
3 a b c 1 2;
Reeza
Super User
Does each ID have only two records each, or can there be multiple records per ID? Is there a limit to how many there can be?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 675 views
  • 0 likes
  • 3 in conversation