BookmarkSubscribeRSS Feed
Fluorite | Level 6

After running a mixed model on 16 different treatments, where I also compare among the treatments I save the differences in a new file. With this new file I run a proc sgplot to create a difference plot showing the differences with respective confidence limit. In order for me to make this readable I put in a where between and statement to have it select all the differences for the comparisons between treatment 1vs2 till 1vs16. For some reason it fails to show what I want it to show when the second part contains double digits. To show what happens:

proc sgplot data=differences noautolegend;
where comparison between '1vs2' and'1vs9';

-->gives me the plot showing all comparisons between 1vs2 till 1vs9




proc sgplot data=differences noautolegend;
where comparison between '1vs2' and'1vs16';

-->only gives me the differences for 1vs2 and 1vs16 without any in between



It has to do with the second 1vs statement having double digits, because as soon as I change that it messes up the graph. It has to do with the way SAS reads this comparison, but does anyone have a solution for this??


Thanks in advance,

Super User

Interval comparisons with character values do not use the numeric values for comparison. Since 2>1 in character values then '1vs2' is greater than '1vs16'. Since you state 16 treatments I am assuming that you have none such as '1vs18' that might have been included.

Please see for an example of sort order which is used in "between" comparisons:

data junk;
   length str $ 5;
   do i=1 to 16;

proc sort data=junk;
   by str;

proc print data=junk;
   var str;

If you want that kind of name to compare properly with "between" you would have to have values for comparison like '1vs02', not '1vs2'.


Or list the exact values you want in the where statement.


That's because the comparison of '1vs1' and '1vs16' is using "lexicographic ordering".   And since your lower-order versions are vs1, vs2, ... vs9  instead of 'vs01','vs02',... 'vs09', you don't have the option of where comparison between '1vs01' and '1vs16'



   where (comparison between '1vs2' and '1vs9') or (comparison between '1vs10' and '1vs16')

The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets



Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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