All,
I have a class variable: time_to_graduation
Time_to_graduation has the following possibilities:
'3-Year and Under Graduate'
'4-Year Graduate'
'5-Year Graduate'
'6-Year Graduate'
'7-Year Graduate'
'8-Year Graduate'
'9-Year Graduate'
'10-Year Graduate'
They are not tabulating in order I have listed. I numbered them intuitively hoping I wouldn't have to do any type of format step. Those hopes, however, were dashed when I tabulated the variable. Let's just say, they are not in order. I've attempted various fixes, but I can't seem to get it to work.
Any advice on getting the tabulation to display the time_to_graduate class variable to tabulate in the order i have above?
Thanks!
As a character string, the values are alphabetized. Since "1" alphabetizes before other digits, "10" will come out first. A simple fix would be to add a blank before all the single-digit values:
' 3-Year and Under Graduate'
Replace them with codes, 1, 2, 3 etc in the correct order and then use a format to have the value displayed instead.
@eer_seer wrote:
All,
I have a class variable: time_to_graduation
Time_to_graduation has the following possibilities:
'3-Year and Under Graduate'
'4-Year Graduate'
'5-Year Graduate'
'6-Year Graduate'
'7-Year Graduate'
'8-Year Graduate'
'9-Year Graduate'
'10-Year Graduate'
They are not tabulating in order I have listed. I numbered them intuitively hoping I wouldn't have to do any type of format step. Those hopes, however, were dashed when I tabulated the variable. Let's just say, they are not in order. I've attempted various fixes, but I can't seem to get it to work.
Any advice on getting the tabulation to display the time_to_graduate class variable to tabulate in the order i have above?
Thanks!
I follow on the first part of your suggestion, don't follow on the second.
As a character string, the values are alphabetized. Since "1" alphabetizes before other digits, "10" will come out first. A simple fix would be to add a blank before all the single-digit values:
' 3-Year and Under Graduate'
This was a great and simple solution to the problem and worked just as you described. Thank you.
Check out the CLASSDATA= option it allows you to provide the data in a specific sequence. Additionally it provides a way to provide class values for which there is no data.
Here is an example:
data have;
infile cards dsd;
input
gradText : $30.
;
seqNr + 1;
random = rand("uniform");
someValue = ceil( random * 100 );
cards;
'3-Year and Under Graduate'
'4-Year Graduate'
'5-Year Graduate'
'6-Year Graduate'
'7-Year Graduate'
'8-Year Graduate'
'9-Year Graduate'
'10-Year Graduate'
;
data classOrder;
set have;
keep gradtext;
run;
proc sort data=have out=have2;
by random;
run;
proc tabulate data=have2 classdata=classorder;
class gradText / order=data;
var someValue;
table
gradText, someValue
;
run;
Ok, great!
This is helpful as well.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.