03-07-2015 05:02 AM
I have 3 columns of data shown in the table below. It's the same format that exist in my data set. I want minimum 1-R2 value of each cluster against their cluster name.
The desired output is shown in the table below :
Thanks in anticipation!
03-07-2015 05:30 AM
So your input data is like a report?
Use retain in the data step to get the cluster name/no on each line.
But how do you chose which "variable" 1-R**2 Ratio-values to keep if there are many that have the same value, the original order?
If so, you could a couple of different techniques. One is to again use retain to keep track on the minimum value. Then read the output database.
Another can be to use SQL. Use monotonic() to keep track of original sorting order, and use having min(row_no) = row_no and min(1-R**2 Ratio) = 1-R**2 Ratio
03-07-2015 09:29 AM
Search for RETAIN statement. There you will have syntax and tons of samples.
By reading your response, I think you need some basic SAS programming training.
03-07-2015 09:48 AM
RETAIN can't magically fix your data problem as implied by @linus you will need some kind of additional logic. I like to use UPDATE for this, it can fix a number of variables without having to do too much work.
03-07-2015 09:59 AM
Something like this. This doesn't answer multiple variables with same low ratio. Jim
Data; retain cluster $8.;
input @1 clu $8. @20 variable $8. @35 ratio;
if clu=:'clust' then cluster=clu; **** grab cluster;
proc sort; by cluster ratio;
data new; set; by cluster;
if first.cluster then output; **** lowest ratio;
proc print; run;