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

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

1 ACCEPTED SOLUTION

Accepted Solutions
jakarman
Barite | Level 11

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

3 REPLIES 3
jakarman
Barite | Level 11

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 --<-----
Jonate_H
Quartz | Level 8

Thanks a lot for the explanation.

Ksharp
Super User

As Jaap pointed out.

It is

PROC FEDSQL;

not

PROC SQL;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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