New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
radhikaa4
Calcite | Level 5

Hi I would like to create a boxplot for multiple variables but not just 1 variable

 

IDtime_hour_1time_hour_2time_hour_3time_hour_4
1401222112
2201121266
3301431443
4351451743
5221241012

 

I tried Proc Boxplot data = a.test;

hbar time_hour_1 time_hour_2;

RUN;

 

Not working. thanks!

2 REPLIES 2
Reeza
Super User

Of course it doesn't, HBAR isn't listed under PROC BOXPLOT, HBAR stands for horizontal bar so not sure why you think that makes sense here either. 

 

Take a look at the documentation first, they have an example that's really close to yours. 

Note that the issue is the structure of your data. Determine how to change your data structure to match theirs and you can use the exact code in the documentation (hint: PROC TRANSPOSE). 

 

https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_boxplot_examples02.htm&docsetVers...

 

Note that at the top of the page, there's a link to the full code if you want, which gets you the full program to run and play with. 

Reeza
Super User

Two different ways to do this, using SGPLOT instead.

 

data have;
    input ID time_hour_1 time_hour_2 time_hour_3 time_hour_4;
    cards;
1   40  122 21  12
2   20  112 12  66
3   30  143 14  43
4   35  145 17  43
5   22  124 10  12
;
    ;
    ;;
run;

data long;
    set have;
    array tm(*) time_hour_1 - time_hour_4;

    do i=1 to dim(tm);
        hour=compress(vname(tm(i)), 'kd');
        Value=tm(i);
        output;
    end;
    keep id hour value;
run;

proc sgplot data=long;
    vbox value / group=hour;
run;

proc sgplot data=have;
    vbox time_hour_1;
    vbox time_hour_2;
run;

@radhikaa4 wrote:

Hi I would like to create a boxplot for multiple variables but not just 1 variable

 

ID time_hour_1 time_hour_2 time_hour_3 time_hour_4
1 40 122 21 12
2 20 112 12 66
3 30 143 14 43
4 35 145 17 43
5 22 124 10 12

 

I tried Proc Boxplot data = a.test;

hbar time_hour_1 time_hour_2;

RUN;

 

Not working. thanks!


 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 13635 views
  • 0 likes
  • 2 in conversation