Proc tabulate - limiting/restraining

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Proc tabulate - limiting/restraining

I am very new to proc tabulate, moving over from DDE for table creation.

I have 2 related questions regarding proc tabulate.

1.

I have two sites, call them site1 and site2. I have events, 36 in total, 17 for site1 and 19 for site2. each site can only have its event take place, site1 will only experience event 1-17, and site2 will only experience events 18-36.

Proc tabulate puts site_1 and site_2 against these, so that what is printing is

site_1 X event1 - event36

site_2 X event1- event36.

I would like each site to sent against the applicable variables, not all vars.

2.

,I would like site1 put against ALL of its possible 17 events, and site2 against ALL of its 19 events.

I have enabled all the "print if missing" options that I could find in my searching before asking this question.

Now, there will be lines of all zeros printed for both sites, but if the event never takes place for either site, the entire event is not printed.


Accepted Solutions
Solution
‎02-18-2015 06:15 PM
Grand Advisor
Posts: 10,210

Re: Proc tabulate - limiting/restraining

Actually you're pretty close. The bit you want is a custom multilabel format based on your ae_code.

Have two codes ae_code1 and ae_code2 with the with the values separated as you would for site1/site2.

Instead of a bunch of if/then:

If ae_code in (1,2,3, <list of code values for site 1>) then ae_code1=ae_code;

if ae_code in (17,18,19, <list of codes for site 2>) then ae_code2 = ae_code;

The table statement would look more like:

    table ae_code1='Operation site' ae_code2='Non-Operative site' all='Totals'  ,

          

            onset_day=' '*(group_table=' '*n=' ' * [style=<parent>])

            all='Totals' * (group_table=' ' *n=' ' * [style=<parent>])

            / misstext='0'  printmiss box='';

I'm not sure how you are getting the text from the ae_code but I assume it is a format. Split the format into corresponding pieces for each ae_code variable. A nice feature would be to make them such as:

1="   text". The spaces would be preserved using a classlev statement:

classlev ae_code1 /style={asis=on};

You might want to make the ae_code variables use the option PRELOADFMT on the class statement so that all levels of the code always appear in the table.

Another approach would be a multilabel format for the existing AE_code but that would have the side effect of also summarizing at the site total.

View solution in original post


All Replies
Grand Advisor
Posts: 10,210

Re: Proc tabulate - limiting/restraining

It would help if you could post some example data, possibly with only 3 of the events for each site, and what the table should look like.

Your data structure can have a lot of impact on which options and/or report procedure to use.

Do you  have one even variable with up to 36 values or 36 variables? Are you looking for counts or other statistic? Do you have one site variable with 2 levels or two site variables?

If your event variable(s) are on class statements you likely need the option missing.

Depending on what you want for actual table(s) appearance it may be that summarizing the data before display works better but we do need to know how your current data is structured and the actual appearance you want.

Occasional Contributor
Posts: 14

Re: Proc tabulate - limiting/restraining

The excel table is an example of what the end result should be like, I used to fill with dde.

The sas pictures is where I am at in using tabulate.

The data comes from separate sets. one data set feeds site1, second data set feeds site2, third data set contains dates for both data set one and two. dataset one has variable codeae1 which is character, second dataset has symptom1 which is numeric.

after combining all data sets, i created new variable called ae_code which was numbered 1-36,

if codeae1 = 1 then ae_code = 1;

...

else if codeae1 = 16 then ae_code =16;

if symptom1 = 1 then ae_code = 17;

...

else if symptom1= 18 then ae_code = 36

then i went through and set up variable "site" by

if ae_code = 1 then site =1

...

else if ae_code = 16 then site = 1

else if ae_code =17 then site =2

...

else if ae_code = 36 then site = 2

here is my proc tab code

proc tabulate data= AE_main S=[just = c] out=testout;

    class site group_table / ;

    class ae_code / missing;

    class onset_day / missing;

    classlev group_table / style=[background=grp_color_format.];

    table (site='' )* (ae_code='' all='Totals')  ,

           

            onset_day=' '*(group_table=' '*n=' ' * [style=<parent>])

            all='Totals' * (group_table=' ' *n=' ' * [style=<parent>])

            / misstext='0'  printmiss box='';

SAS table snip.JPG

table_snip.JPG

Solution
‎02-18-2015 06:15 PM
Grand Advisor
Posts: 10,210

Re: Proc tabulate - limiting/restraining

Actually you're pretty close. The bit you want is a custom multilabel format based on your ae_code.

Have two codes ae_code1 and ae_code2 with the with the values separated as you would for site1/site2.

Instead of a bunch of if/then:

If ae_code in (1,2,3, <list of code values for site 1>) then ae_code1=ae_code;

if ae_code in (17,18,19, <list of codes for site 2>) then ae_code2 = ae_code;

The table statement would look more like:

    table ae_code1='Operation site' ae_code2='Non-Operative site' all='Totals'  ,

          

            onset_day=' '*(group_table=' '*n=' ' * [style=<parent>])

            all='Totals' * (group_table=' ' *n=' ' * [style=<parent>])

            / misstext='0'  printmiss box='';

I'm not sure how you are getting the text from the ae_code but I assume it is a format. Split the format into corresponding pieces for each ae_code variable. A nice feature would be to make them such as:

1="   text". The spaces would be preserved using a classlev statement:

classlev ae_code1 /style={asis=on};

You might want to make the ae_code variables use the option PRELOADFMT on the class statement so that all levels of the code always appear in the table.

Another approach would be a multilabel format for the existing AE_code but that would have the side effect of also summarizing at the site total.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 239 views
  • 0 likes
  • 2 in conversation