BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

Hi, I have inputed text data (see CODE1 below, and I want the CI1 to remain in the same order when I run it though proc tabulate.  But instead it sorts it as such (see OUTPUT1).  I'm using the TABULATE code (see CODE2).  thanks

CODE1:

if Vendor_1 < -0.20 then CI1 = '<=-20.1%';

else if Vendor_1 < -0.15 and Vendor_1 => -0.20 then CI1 = '-15.1% => and => -20%';

else if Vendor_1 < -0.12 and Vendor_1 => -0.15 then CI1 = '-12.1% => and => -15%';

else if Vendor_1 < -0.10 and Vendor_1 => -0.12 then CI1 = '-10.1% => and => -12%';

else if Vendor_1 < -0.08 and Vendor_1 => -0.10 then CI1 = '-8.1% => and => -10%';

else if Vendor_1 < -0.05 and Vendor_1 => -0.08 then CI1 = '-5.1% => and => -8%';

else if Vendor_1 <= 0 and Vendor_1 => -0.05 then CI1 = '0.0% => and => -5%';

else if Vendor_1 > 0 and Vendor_1 <= 0.05 then CI1 = '0.1% <= and <= 5%';

else if Vendor_1 > 0.05 and Vendor_1 <= 0.08 then CI1 = '5.1% <= and <= 8%';

else if Vendor_1 > 0.08 and Vendor_1 <= 0.10 then CI1 = '8.1% <= and <= 10%';

else if Vendor_1 > 0.10 and Vendor_1 <= 0.12 then CI1 = '10.1 <= and <= 12%';

else if Vendor_1 > 0.12 and Vendor_1 <= 0.15 then CI1 = '12.1% <= and <= 15%';

else if Vendor_1 > 0.15 then CI1 = '>15%'; else CI1 = 'ZZZ';

end;

end;

OUTPUT1:

-10.1% => and => -12%
-12.1% => and => -15%
-15.1% => and => -20%
-5.1% => and => -8%
-8.1% => and => -10%
0.0% => and => -5%
0.1% <= and <= 5%
10.1 <= and <= 12%
12.1% <= and <= 15%
5.1% <= and <= 8%
8.1% <= and <= 10%
<=-20.1%
>15%

CODE2:

PROC TABULATE data=Test;

CLASS USE_CI CI1 Vendor_1;

var count;

TABLE Vendor_1*CI1,pctn<CI1 all>  /rts=35;

RUN;

5 REPLIES 5
Linlin
Lapis Lazuli | Level 10

changing code to:

proc tabulate data=test order=data;

podarum
Quartz | Level 8

Doing that, I got :

>15%
-10.1% => and => -12%
<=-20.1%
-15.1% => and => -20%
-8.1% => and => -10%
0.1% <= and <= 5%
0.0% => and => -5%
-12.1% => and => -15%
5.1% <= and <= 8%
-5.1% => and => -8%
12.1% <= and <= 15%
8.1% <= and <= 10%
10.1 <= and <= 12%
ballardw
Super User

For use with ORDER=DATA sometimes it helps to sort the data so the order is as expected.

Linlin
Lapis Lazuli | Level 10

please sort your data by Vendor_1 , then run proc tabulate. something like this:

proc sort data=your_dataset out=temp;

by vender_1;

run;

proc tabulate data=temp order=data;

podarum
Quartz | Level 8

Thank you.. worked fine.

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
  • 5 replies
  • 1048 views
  • 0 likes
  • 3 in conversation