<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971222#M377290</link>
    <description>&lt;P&gt;You can use the formula for the CDF (see Wikipedia) to implement the CDF. You can either do it inline in the DATA step or define the CDF in PROC FCMP and then call it from the DATA step. I implement the second option below:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.ProbDist;
function GEV_CDF(x, mu, sigma, xi);
   /* CDF formula from 
      https://en.wikipedia.org/wiki/Generalized_extreme_value_distribution
   */
   if sigma &amp;lt;= 0 then return(.);
   z = (x-mu)/sigma;
   if xi=0 then
      CDF = exp(-exp(-z));
   else if xi^=0 and xi*z &amp;gt; -1 then 
      CDF = exp(-(1 + xi*z)**(-1/xi));
   else if xi &amp;gt; 0 and z &amp;lt;= -1/xi then 
      CDF = 0;
   else if xi &amp;lt; 0 and z &amp;gt;= 1/abs(xi) then
      CDF = 1;
   else 
      CDF = .;
   return (CDF);
endsub;
run;

options cmplib=work.funcs;  /* define location of SafeLog function */
data GEV_Test;
mu = 10;
sigma = 2;
xi = 0.5;
do x = 0 to 25 by 0.1;
   CDF = GEV_CDF(x, mu, sigma, xi);
   output;
end;
run;

title "Generalized Extreme Value CDF";
title2 "mu = 10; sigma = 2; xi = 0.5;";
proc sgplot data=GEV_Test;
   series x=x y=CDF;
   yaxis grid min=0 max=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Jul 2025 14:40:47 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2025-07-21T14:40:47Z</dc:date>
    <item>
      <title>Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971172#M377274</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I previously read that the Cumulative Distribution Function (CDF) for the Generalized Extreme Value (GEV) distribution can be calculated using the CDF function with the 'GEV' distribution type, where the syntax is: CDF('GEV', x, mu, sigma, xi).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following was given as an example code:&lt;BR /&gt;data _null_;&lt;BR /&gt;mu = 10;&lt;BR /&gt;sigma = 2;&lt;BR /&gt;xi = 0.5;&lt;BR /&gt;x = 12;&lt;BR /&gt;cdf_value = CDF('GEV', x, mu, sigma, xi);&lt;BR /&gt;put cdf_value;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Upon implementing the example code in SAS 9.5, I got the following error:&lt;BR /&gt;106 data _null_;&lt;BR /&gt;107&lt;BR /&gt;108 mu = 10;&lt;BR /&gt;109&lt;BR /&gt;110 sigma = 2;&lt;BR /&gt;111&lt;BR /&gt;112 xi = 0.5;&lt;BR /&gt;113&lt;BR /&gt;114 x = 12;&lt;BR /&gt;115&lt;BR /&gt;116 cdf_value = CDF('GEV', x, mu, sigma, xi);&lt;BR /&gt;117&lt;BR /&gt;118 put cdf_value;&lt;BR /&gt;119 run;&lt;BR /&gt;ERROR: The first argument of the CDF function must be a character string with a value of BERNOULLI,&lt;BR /&gt;BETA, BINOMIAL, CAUCHY, CHISQUARE, EXPONENTIAL, F, GAMMA, GAUSSIAN, GEOMETRIC, GENPOISSON,&lt;BR /&gt;HYPERGEOMETRIC, IGAUSS, LAPLACE, LOGISTIC, LOGNORMAL, NEGB, NORMAL, NORMALMIX, PARETO,&lt;BR /&gt;POISSON, T, UNIFORM, WALD or WEIBULL.&lt;BR /&gt;NOTE: Argument 1 to function CDF('GEV',12,10,2,0.5) at line 116 column 15 is invalid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How can this error be resolved?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jul 2025 17:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971172#M377274</guid>
      <dc:creator>Tom25</dc:creator>
      <dc:date>2025-07-20T17:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971174#M377276</link>
      <description>&lt;P&gt;There is no SAS 9.5 yet (unless you're a SAS insider and doing some early testing of unreleased software. : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message is clear.&amp;nbsp; 'GEV' is not an allowed value for for that first argument.&amp;nbsp; Was it maybe ChatGPT or similar that told you it would work? One of the interesting things about the LLMs is that even when they 'hallucinate' they can do it in ways that make sense.&amp;nbsp; There could be a 'GEV' argument, and it might be reasonable to assume that there is a 'GEV' argument, but there isn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have PROC IML, this blog post from Rick Wicklin might be a helpful approach:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/07/24/gumbel-distribution-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2019/07/24/gumbel-distribution-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jul 2025 18:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971174#M377276</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-07-20T18:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971222#M377290</link>
      <description>&lt;P&gt;You can use the formula for the CDF (see Wikipedia) to implement the CDF. You can either do it inline in the DATA step or define the CDF in PROC FCMP and then call it from the DATA step. I implement the second option below:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.ProbDist;
function GEV_CDF(x, mu, sigma, xi);
   /* CDF formula from 
      https://en.wikipedia.org/wiki/Generalized_extreme_value_distribution
   */
   if sigma &amp;lt;= 0 then return(.);
   z = (x-mu)/sigma;
   if xi=0 then
      CDF = exp(-exp(-z));
   else if xi^=0 and xi*z &amp;gt; -1 then 
      CDF = exp(-(1 + xi*z)**(-1/xi));
   else if xi &amp;gt; 0 and z &amp;lt;= -1/xi then 
      CDF = 0;
   else if xi &amp;lt; 0 and z &amp;gt;= 1/abs(xi) then
      CDF = 1;
   else 
      CDF = .;
   return (CDF);
endsub;
run;

options cmplib=work.funcs;  /* define location of SafeLog function */
data GEV_Test;
mu = 10;
sigma = 2;
xi = 0.5;
do x = 0 to 25 by 0.1;
   CDF = GEV_CDF(x, mu, sigma, xi);
   output;
end;
run;

title "Generalized Extreme Value CDF";
title2 "mu = 10; sigma = 2; xi = 0.5;";
proc sgplot data=GEV_Test;
   series x=x y=CDF;
   yaxis grid min=0 max=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Jul 2025 14:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971222#M377290</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-07-21T14:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971419#M377329</link>
      <description>&lt;P&gt;Thank you for your response. The 9.5 was a typo. I am using SAS 9.4.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 02:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971419#M377329</guid>
      <dc:creator>Tom25</dc:creator>
      <dc:date>2025-07-24T02:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971420#M377330</link>
      <description>&lt;P&gt;Thank you, Rick, for your response. I have a couple of questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;How can I implement the CDF of the GEV inline in the DATA step?&lt;/LI&gt;&lt;LI&gt;How can I implement the CDF of the GEV inside proc iml?&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Thu, 24 Jul 2025 02:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971420#M377330</guid>
      <dc:creator>Tom25</dc:creator>
      <dc:date>2025-07-24T02:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971433#M377336</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/476334"&gt;@Tom25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;OL&gt;
&lt;LI&gt;How can I implement the CDF of the GEV inline in the DATA step?&lt;/LI&gt;
&lt;LI&gt;How can I implement the CDF of the GEV inside proc iml?&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;1. Copy the body of the FCMP function and paste it into a DATA step. Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* compute CDF directly in DATA step */
data GEV_Test;
mu = 10;
sigma = 2;
xi = 0.5;
do x = 0 to 25 by 1;
   if sigma &amp;lt;= 0 then CDF=.;
   else do;
   z = (x-mu)/sigma;
   if xi=0 then 
      CDF = exp(-exp(-z));
   else if xi^=0 and xi*z &amp;gt; -1 then 
      CDF = exp(-(1 + xi*z)**(-1/xi));
   else if xi &amp;gt; 0 and z &amp;lt;= -1/xi then 
      CDF = 0;
   else if xi &amp;lt; 0 and z &amp;gt;= 1/abs(xi) then 
      CDF = 1;
   else 
      CDF = .;
   end;
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. Paste the body into an IML module that you call for each value of x.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 13:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971433#M377336</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-07-24T13:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971595#M377362</link>
      <description>&lt;P&gt;Thank you, Rick, for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate it if you could post the codes for&amp;nbsp;&lt;SPAN&gt;pasting the data step for calculating the CDF of GEV into an proc IML module that we call for each value of simulated x data from uniform distribution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 21:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971595#M377362</guid>
      <dc:creator>Tom25</dc:creator>
      <dc:date>2025-07-28T21:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971630#M377371</link>
      <description>&lt;P&gt;For a general implementation of the GEV in Base SAS (using PROC FCMP and the DATA step), see the article&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2025/08/25/gev-sas.html" target="_blank"&gt;Implement the generalized extreme value distribution in SAS - The DO Loop&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;which includes functions for the CDF, PDF, quantiles, and random variates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I would appreciate it if you could post the codes for&amp;nbsp;pasting the data step for calculating the CDF of GEV into an proc IML module that we call for each value of simulated x data from uniform distribution.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OK. Here it is. See the article for additional IML modules that compute the CDF, PDF, quantile function, and random variates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* compute CDF in an IML function */
proc iml;
/* this function takes a single scalar value (x) and returns the 
   CDF(x) for the GEV(mu, sigma, xi) distribution */
start GEV_CDF(x, mu, sigma, xi);
   if sigma &amp;lt;= 0 then return(.);
   z = (x-mu)/sigma;
   if xi=0 then 
      CDF = exp(-exp(-z));
   else if xi^=0 &amp;amp; xi*z &amp;gt; -1 then 
      CDF = exp(-(1 + xi*z)##(-1/xi));
   else if xi &amp;gt; 0 &amp;amp; z &amp;lt;= -1/xi then 
      CDF = 0;
   else if xi &amp;lt; 0 &amp;amp; z &amp;gt;= 1/abs(xi) then 
      CDF = 1;
   else 
      CDF = .;
   return( CDF );
finish;

/* set the parameters */
mu = 10;
sigma = 2;
xi = 0.5;

/* compute the CDF function on [0,25] */ 
x = T(do(0,25,0.25));
CDF = j(nrow(x),1);
do i = 1 to nrow(x);
   CDF[i] = GEV_CDF(x[i], mu, sigma, xi);
end;

/* visualize the CDF function */ 
title "CDF for GEV Distribution";
call series(x, CDF) grid={x y};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rick_SAS_0-1753795887036.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108614iF18AE5077776783E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rick_SAS_0-1753795887036.png" alt="Rick_SAS_0-1753795887036.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2025 09:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971630#M377371</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-08-25T09:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Distribution Function (CDF) for Generalized Extreme Value (GEV)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971661#M377378</link>
      <description>&lt;P&gt;Thank you, Rick.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jul 2025 21:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Distribution-Function-CDF-for-Generalized-Extreme/m-p/971661#M377378</guid>
      <dc:creator>Tom25</dc:creator>
      <dc:date>2025-07-29T21:42:59Z</dc:date>
    </item>
  </channel>
</rss>

