Help using Base SAS procedures

Proc Tabulate with Out=

Accepted Solution Solved
Reply
Regular Contributor
Posts: 212
Accepted Solution

Proc Tabulate with Out=

Hi. I'm using Proc Tabulate with the Out= option. In my data I keep 3 variables:

1. rule_order

2. ad_dt

3. n

 

Proc tabulate data=FinalData missing out=testdata (keep=rule_order ad_dt n) ;
class Rule_Order ad_dt;
table rule_order*(ad_dt all)*n;
run;

 

My problem is that the AD_DT's that are missing have a value of . (missing) but my totals by Rule_Order also have a . (missing). In the data I would like to be able to recode the totals that have a . to be 'Total', but I don't see a way to do this.

 

I've attached a sample of what my output dataset Testdata looks like.

 

Any help would be much appreciated.


Capture.PNG

Accepted Solutions
Solution
‎04-07-2016 12:08 PM
Super User
Posts: 11,343

Re: Proc Tabulate with Out=

Posted in reply to buechler66

Look closely at the output data. You will find a variable _type_. This, similar to proc Means and Summary, indicates the combinations of variables used to create the values for a row of the data set. Determine which level(s) of _type_ represent your summary, usually not too difficult unless you have many class variables and "All" clauses.

However you are likely to have serious issues about attempting to assign a value of "Total" to a NUMERIC variable (ie you can't).

 

Depending on complexity you might get away with a custom format to assign a value of 'Total' to missing.

 

 

View solution in original post


All Replies
Super User
Posts: 5,498

Re: Proc Tabulate with Out=

Posted in reply to buechler66

By default, PROC TABULATE omits observations where any CLASS variable has a missing value.  You can have them included by adding the MISSING option.

Super User
Posts: 19,771

Re: Proc Tabulate with Out=

Posted in reply to buechler66
class Rule_Order ad_dt /Missing ;

 

Solution
‎04-07-2016 12:08 PM
Super User
Posts: 11,343

Re: Proc Tabulate with Out=

Posted in reply to buechler66

Look closely at the output data. You will find a variable _type_. This, similar to proc Means and Summary, indicates the combinations of variables used to create the values for a row of the data set. Determine which level(s) of _type_ represent your summary, usually not too difficult unless you have many class variables and "All" clauses.

However you are likely to have serious issues about attempting to assign a value of "Total" to a NUMERIC variable (ie you can't).

 

Depending on complexity you might get away with a custom format to assign a value of 'Total' to missing.

 

 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 402 views
  • 1 like
  • 4 in conversation