BookmarkSubscribeRSS Feed
GavinB
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

 

image.png

 

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

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

image.png

 

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,
Gavin

2 REPLIES 2
ballardw
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;
      str=cats('1vs',i);
      output;
   end;
run;

proc sort data=junk;
   by str;
run;

proc print data=junk;
   var str;
run;

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.

mkeintz
PROC Star

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'

 

Try

   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

--------------------------

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!

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