BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jahanzaib
Quartz | Level 8

I want to winsorize the attached data at 1% and 99% winsorization on the basis of country and family and non family firms. like in this format. can anyone help me?

Country Kor

                                         Book deb ratio
                               N    mean   median  max  min
 Family firms
Non-family firms
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

I used your original 22.xls file .

 

 

proc import datafile='/folders/myfolders/22.xls' out=have replace dbms=xls;mixed=yes;run;
proc format;
value $ fmt
 '0'='Non-family firms'
 '1'='Family firms';
run;
proc sort data=have;by count fam;run;
proc summary data=have ;
by count fam;
var book_debt_ratio;
output out=temp(drop=_freq_ _type_) p1= p99= /autoname;
run;
data want;
 merge have temp;
 by count fam;
 if book_debt_ratio lt book_debt_ratio_P1 then book_debt_ratio=book_debt_ratio_P1;
 if book_debt_ratio gt book_debt_ratio_P99 then book_debt_ratio=book_debt_ratio_P99;
run;

options nobyline;
title  "Country #byval1";
proc tabulate data=want;
by count;
var book_debt_ratio;
class Fam;
format Fam $fmt.;
table Fam=' ',book_debt_ratio*(N    mean   median  max  min);
run;

View solution in original post

3 REPLIES 3
Norman21
Lapis Lazuli | Level 10

Have you had a look at the discussion here?

 

https://communities.sas.com/t5/SAS-Procedures/How-to-winsorize/td-p/214976

 

The discussion includes the difference between winsorising and trimming.

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

Ksharp
Super User

I used your original 22.xls file .

 

 

proc import datafile='/folders/myfolders/22.xls' out=have replace dbms=xls;mixed=yes;run;
proc format;
value $ fmt
 '0'='Non-family firms'
 '1'='Family firms';
run;
proc sort data=have;by count fam;run;
proc summary data=have ;
by count fam;
var book_debt_ratio;
output out=temp(drop=_freq_ _type_) p1= p99= /autoname;
run;
data want;
 merge have temp;
 by count fam;
 if book_debt_ratio lt book_debt_ratio_P1 then book_debt_ratio=book_debt_ratio_P1;
 if book_debt_ratio gt book_debt_ratio_P99 then book_debt_ratio=book_debt_ratio_P99;
run;

options nobyline;
title  "Country #byval1";
proc tabulate data=want;
by count;
var book_debt_ratio;
class Fam;
format Fam $fmt.;
table Fam=' ',book_debt_ratio*(N    mean   median  max  min);
run;
Rick_SAS
SAS Super FREQ

See the discussion and links in the article "How to Winsorize data in SAS."

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1021 views
  • 3 likes
  • 4 in conversation