Medians of Deciled Variables

Reply
Contributor
Posts: 35

Medians of Deciled Variables

Hi, I am relatively new to SAS.

I have first formed deciles within each month, starting from 1965 to 2007. Now I am trying to retrieve the medians of each of the deciles within each month (i.e. Getting the medians from each decile 1 to 10 of Jan 1965, followed by  decile 1 to 10 of Feb 1965... ... ..... decile 1 to 10 of Dec 2007.

I have used the following code:

PROC MEANS

DATA=work.deciled_sort NOPRINT;

CLASS DECILED_MAX_RET;

VAR MAX_RET;

OUTPUT OUT=Deciled_Medians

n=n

median(MAX_RET)=MEDIAN_RET

BY DATENEW;

RUN;

This is the error from the log file:

ERROR: The number of output variables is inconsistent with the number of output names in output statement 1. Output statement will be ignored.

WARNING: No output data set(s) will be created due to error(s) in output statement(s).

ERROR: Neither the PRINT option nor a valid output statement has been given.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.DECILED_MEDIANS may be incomplete.  When this step was stopped there were 0 observations and 4 variables.

NOTE: PROCEDURE MEANS used (Total process time):

      real time           0.03 seconds

      cpu time           0.01 seconds

I cannot figure out where I went from. Please help!

Thank you!

Respected Advisor
Posts: 3,777

Re: Medians of Deciled Variables

Your OUTPUT statement needs a semicolon.

Contributor
Posts: 35

Re: Medians of Deciled Variables

Hmm, After putting in the semicolon, the rest of the code does not work.

Super User
Posts: 10,483

Re: Medians of Deciled Variables

I would try to make sure that my code constructs are parallel so SAS doesn't have to guess about intent of mixed syntax

n(Max_Ret)=n

median(Max_ret)=Median_Ret;
OR

n= median= /autoname autolabel;

Super User
Posts: 10,483

Re: Medians of Deciled Variables

Where did you place the semicolon?

PROC Star
Posts: 1,090

Re: Medians of Deciled Variables

I'm intrigued...this is the first time that I've seen someone take quantiles of data divided into quantiles.

Why is it that you're doing this, if you don't mind my asking?

Tom

Respected Advisor
Posts: 2,655

Re: Medians of Deciled Variables

Me too.  And wouldn't the median of the first decile be the 5th percentile, of the second decile the 15th, etc.?  Seems like it would be a lot easier to just do:

proc univariate data=originaldataset;

class month;

var max_ret;

output out=newdataset pctlpts=5 to 95 by 10;

run;

instead of the two step procedure.

But I could really be wrong about the median of the deciles.

Steve Denham

Contributor
Posts: 35

Re: Medians of Deciled Variables

Hi Tom,

I am actually taking the median from each decile, and not dividing the deciles again. (If I get you correctly). I am just trying to get a representative observation for each decile. Then combine all of the medians of each month for a few years. To see if a pattern exist.

Contributor
Posts: 35

Re: Medians of Deciled Variables

Hi Guys,

Actually this code was just what I needed (Just a little variation from the 1 I posted earlier):

'

PROC MEANS

DATA=work.deciled_sort NOPRINT;

CLASS DATENEW DECILED_MAX_RET;

VAR MAX_RET;

OUTPUT OUT=Deciled_Medians

n=n

median(MAX_RET)=MEDIAN_RET;

RUN;

PROC Star
Posts: 1,090

Re: Medians of Deciled Variables

To Benn:

Cool! Never seen that one before, but it makes sense.

To Steve Denham:

I thought the same thing, that a median of a decile would be a p5. But I had some time, and played around with it, and with designed data values the two can be made very different, so I would definitely use UNIVARIATE and a p5 like you demonstrated rather than the decile/median combo.

Nifty stuff,

  Tom

Ask a Question
Discussion stats
  • 9 replies
  • 1104 views
  • 1 like
  • 5 in conversation