DATA Step, Macro, Functions and more

Making a Table

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Making a Table

I am trying to make a table with Sale Years on the left side, and Use Codes along the top. Here is my program I am running:

proc tabulate data=stats14f;
	class sale_yr dor_uc;
	var median_prc;
	table sale_yr, dor_uc;
run;

 

And this is what I end up with:

table.png

 

How do I get the table to show my median_prc data instead of just N? Should I even be running the proc tabulate statement or is there something else?


Accepted Solutions
Solution
‎08-30-2017 03:40 PM
Super User
Posts: 19,822

Re: Making a Table

Posted in reply to andrewfau

N is the default statistic. For a median add the keyword MEDIAN after the variable, ie Yearly median for the stock price.

proc tabulate data=sashelp.stocks;
class date stock ;
var open;
format date year4.;
table stock, date*open*(median);
run;

View solution in original post


All Replies
Solution
‎08-30-2017 03:40 PM
Super User
Posts: 19,822

Re: Making a Table

Posted in reply to andrewfau

N is the default statistic. For a median add the keyword MEDIAN after the variable, ie Yearly median for the stock price.

proc tabulate data=sashelp.stocks;
class date stock ;
var open;
format date year4.;
table stock, date*open*(median);
run;
Contributor
Posts: 22

Re: Making a Table

proc tabulate data=stats14f;
	class sale_yr dor_uc;
	var median_prc;
	table sale_yr, dor_uc*median_prc*(MEDIAN);
run;
Super User
Posts: 19,822

Re: Making a Table

Posted in reply to andrewfau

I misunderstood your question, my answer above is not correct. 

It's showing the median of the variable median price. If you have data and want to display it, not calculate summary statistics then PROC TABULATE is not the correct procedure. 

You should be using PROC REPORT, and include the variable for the columns as an ACROSS type in the DEFINE statement.

 

Super User
Posts: 5,513

Re: Making a Table

Posted in reply to andrewfau

The VAR statement allows you to use MEDIAN_PRC in your table. However, it's still up to you whether you want to use it or not.

 

Is MEDIAN_PRC actually the name of one of your variables?  Does your data already contain a single observation for each combination of SALE_YR and DOR_UC?  If so, you could code:

 

table sale_yr, dor_uc * median_prc * mean=' ';

 

But if MEDIAN_PRC is not one of your existing variables, you'll have to explain what variables are in your data set.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 123 views
  • 0 likes
  • 3 in conversation