BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Chang
Quartz | Level 8

hi,

 

I have several CSV files that contain correlations between two variables. These correlations were computed using twin modelling in R. The name of the two variables are in column depVar1 and depVar2. An example of duplication here is that the correlation between A and B duplicates the correlation between B and A:

  • depVar1=A, depVar2=B
  • depVar1=B, depVar2=A (this is a duplicate of the above)

To illustrate, I've groupped some rows by color and bold their duplicates as shown by the screenshot belows. Not all the duplicated rows are bold. However, values from column D to column K are the same in duplicated rows. I thought of removing duplicated rows by column D~ K. However, this is risky because different combinations of 2 variables can have same correlations. My data have been attached. There are 20 rows in the data. There should be 10 rows left after the removal of the duplicates. Thanks in advance.

 

duplicates_in_bivariate_modelling.png

 

Chang

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

proc import datafile='c:\temp\_biVar_all_correlations_b.csv' out=have dbms=csv replace;
run;
data temp;
 set have;
 length new1 new2 $ 40;
 new1=depvar1;
 new2=depvar2;
 call sortc(new1,new2);
run;
proc sort data=temp out=want nodupkey;
by new1 new2;
run;


View solution in original post

3 REPLIES 3
Astounding
PROC Star

If you always have the matching pair in your data, it should be easy to code:

 

if depvar1 > depvar2 then delete;

Ksharp
Super User

proc import datafile='c:\temp\_biVar_all_correlations_b.csv' out=have dbms=csv replace;
run;
data temp;
 set have;
 length new1 new2 $ 40;
 new1=depvar1;
 new2=depvar2;
 call sortc(new1,new2);
run;
proc sort data=temp out=want nodupkey;
by new1 new2;
run;


Chang
Quartz | Level 8

Thanks. That's an elegant solution!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 17377 views
  • 1 like
  • 3 in conversation