Help using Base SAS procedures

calculate quantile

Reply
Contributor mei
Contributor
Posts: 62

calculate quantile

Dear Sir,

I wish to split my sample to 3 groups based on total assets (variable:at), ie to small firm, medium firm and big firm. this means i need to calculate the 1/3 quantile, 2/3 quantile for the variable.

How do i write that in the program?

also: if i wish to split to 4 parts, i suppose Q1, median, Q3 that is generated from the normal univariate procedure would be fine right?

Thanks a lot!!

Valued Guide
Posts: 765

Re: calculate quantile

hi ... quantiles and the median are based on counts, not magnitude of numbers so that approach will not categorize small/ medium/large

for example, if I looked at this data, I might say that 1 is small, 100 is medium, 1000 is large ... but the quantiles and median don't say that

data test;

input assets @@;

datalines;

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 1000

;

proc univariate data=test;

ods select quantiles;

run;


Variable:  assets

Quantiles (Definition 5)

Quantile      Estimate

100% Max          1000

99%               1000

95%                100

90%                100

75% Q3               1

50% Median           1

25% Q1               1

10%                  1

5%                   1

1%                   1

0% Min               1

Contributor mei
Contributor
Posts: 62

Re: calculate quantile

it is okay, i just want the count as my data size is very big, up to 20,000 observations. i just need to split them to 3 groups.

can you guide me in writing the codes to 3 parts?

Valued Guide
Posts: 765

Re: calculate quantile

hi ... specify the number of groups in GROUPS= ... the lowest group is always 0

with three groups, the value of ASSET_GROUP  will be 0, 1, 2

proc rank data=test out=test_group groups=3 ties=low;

var assets;

ranks asset_group;

run;


(you can look at online help for an explanation of TIES=)

Ask a Question
Discussion stats
  • 3 replies
  • 217 views
  • 0 likes
  • 2 in conversation