skewness and kurtosis in proc sql

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 130
Accepted Solution

skewness and kurtosis in proc sql

My SAS version is 9.4 TS Level 1M2

.I tried something like below, it didn't work, the log error is about:

ERROR: Function SKEWNESS requires at least 3 argument(s).

ERROR: Function KURTOSIS requires at least 4 argument(s).

%let window=2;

proc sql;

create table want as

   select *,

   (select skewness(var_x) from have where id=a.id and year between a.year and (a.year + &window)) as var_x_skewness,

   (select kurtosis(var_x) from have where id=a.id and year between a.year and (a.year + &window)) as var_x_kurtosis

from have as a;

quit;

Then I searched online, looks like both functions can't use directly in proc sql.

but I also found something  as highlighted below in the following link,

SAS(R) 9.4 FedSQL Language Reference, Fourth Edition

The following statement illustrates the SKEWNESS function:

Statements                                                             Results

select skewness(AvgHigh) from worldtemps;             -0.69811


Accepted Solutions
Solution
‎08-04-2015 03:39 PM
Valued Guide
Posts: 3,206

Re: skewness and kurtosis in proc sql

You are mixing up several concepts.

- Skewness can be computed as of some tables (sas-datasets) This is done with SAS by proc usage means/univariate Base SAS(R) 9.2 Procedures Guide

  The calculation is done horizontally. This is normal classic sas usage.

- Skewness can be calculated on some number of variables in a records.. SAS has a function for that SAS(R) 9.4 Functions and CALL Routines: Reference, Fourth Edition

- With Proc Sql SAS kept that on the ANSI 99 standard not following it to 2013 (interval group calculations)

  When coding whit that SQL you can call the SAS functions (horizontally) not the SQL vertically grouping way

- With PROC FEDSQL you have a part of a new SQL ANSI  version grouping is mentioned hey have been implemented as addons with aggregate functions (sql:99)  
  intended to be used with DS2 and supporting skewness vertical and horizontal     

---->-- ja karman --<-----

View solution in original post


All Replies
Solution
‎08-04-2015 03:39 PM
Valued Guide
Posts: 3,206

Re: skewness and kurtosis in proc sql

You are mixing up several concepts.

- Skewness can be computed as of some tables (sas-datasets) This is done with SAS by proc usage means/univariate Base SAS(R) 9.2 Procedures Guide

  The calculation is done horizontally. This is normal classic sas usage.

- Skewness can be calculated on some number of variables in a records.. SAS has a function for that SAS(R) 9.4 Functions and CALL Routines: Reference, Fourth Edition

- With Proc Sql SAS kept that on the ANSI 99 standard not following it to 2013 (interval group calculations)

  When coding whit that SQL you can call the SAS functions (horizontally) not the SQL vertically grouping way

- With PROC FEDSQL you have a part of a new SQL ANSI  version grouping is mentioned hey have been implemented as addons with aggregate functions (sql:99)  
  intended to be used with DS2 and supporting skewness vertical and horizontal     

---->-- ja karman --<-----
Frequent Contributor
Posts: 130

Re: skewness and kurtosis in proc sql

Thanks a lot for the explanation.

Grand Advisor
Posts: 9,593

Re: skewness and kurtosis in proc sql

As Jaap pointed out.

It is

PROC FEDSQL;

not

PROC SQL;

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 866 views
  • 0 likes
  • 3 in conversation