Hi, Hope someone can help me out of the mess I'm in with Proc tabulate.
I have this statement:
proc tabulate data = dataIn;
var catCount;
class studyID orderBy dttm desc type;
table studyID*type*orderBy*desc*(style=Header),
catCount*dttm*max=' ';
run;
This works ok except I need to order the analysis variable going from left to right across the table by the datetime field dttm. How can I specify dttm to be ordered as either asc or desc?
This is what I need.
studyID | Type | OrderBy | Desc | 01/01/2014 | 02/01/2014 | 03/01/2014 |
---|---|---|---|---|---|---|
xyz | Subject | 1 | Screened | |||
2 | Randomised | |||||
Form | 3 | SDV | ||||
4 | Locked | |||||
Query | 5 | Genrated | ||||
6 | Outstanding |
you need to look a the documentation for the CLASS statment.
You can have multiple class statements so you can set class options differently for different variables. So
Class dttm / ascending; or Class dttm / descending;
If I understand your comment about the analysis variable I think you may want dttm=''*catcount=''*max='';
There are a couple of ways that you can order data within a table, using options in the PROC TABULATE statement itself, or within a CLASS statement. I think what you will want to do is use the CLASS statement.
Within a CLASS statement you can order the data in the following ways (from the documentation):
ORDER=DATA | FORMATTED | FREQ | UNFORMATTED
DATA: orders values according to their order in the input data set.
FORMATTED: orders values by their ascending formatted values. This order depends on your operating environment.
FREQ: orders values by descending frequency count.
UNFORMATTED: orders values by their unformatted values, which yields the same order as PROC SORT.
proc tabulate data = dataIn;
var catCount;
class dttm / order = data;
class studyID orderBy desc type;
table studyID*type*orderBy*desc*(style=Header),
catCount*dttm*max=' ';
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.