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

Hi! I would like to ask a question regarding CDF Tweedie in SAS. I read this link

http://documentation.sas.com/?docsetId=ds2ref&docsetTarget=n0sqs8cpv6ucnkn1upsfmy7tm3yl.htm&docsetVe... , and I found this statement : 

y=cdf('TWEEDIE', .8, 5)

But the statement won't work in my SAS University Edition. The result is :

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 y=cdf('TWEEDIE', 0.8, 5);
_
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
74
75 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
88

 

Anyone knows why is it like this? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You can run the CDF function in the DATA step. No need to use DS2.

 

data Tweedie;
do x = 0 to 3 by 0.05;
   y=cdf('TWEEDIE', x, 5);
   output;
end;
run;

title "CDF of the Tweedie(5) Distribution";
proc sgplot data=Tweedie;
   series x=x y=y;
run;

 

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

CDF is a function, and is part of the proc ds2 step.

https://blogs.sas.com/content/sgf/2016/02/19/reasons-love-proc-ds2/

 

You have to write the procedure to generate this, to start with:

proc ds2;
  ...
quit;

Put your statements in where the elipses are.

nikolasfilbert
Fluorite | Level 6

I wrote it like this :


proc ds2;
y=cdf('TWEEDIE', 0.8, 5);
quit;

 

but there is no output, and I got this log:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 proc ds2;
74 y=cdf('TWEEDIE', 0.8, 5);
75 quit;
 
WARNING: Some DS2 statements have not been executed. Use the RUN; statement to execute DS2 statements before QUIT;.
NOTE: PROCEDURE DS2 used (Total process time):
real time 0.05 seconds
cpu time 0.03 seconds
 
 
76
77 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
90
 
Can you tell me why?
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Am afraid I can't, I don't use DS2 procedure.  You need to learn how to use it, its syntax and logic.  Start with the SAS help and work from there.

http://documentation.sas.com/?docsetId=proc&docsetTarget=p1im5eq2oxakk5n1gr3jl7ruc8a0.htm&docsetVers...

art297
Opal | Level 21

@nikolasfilbert: I am not familiar with DS2, but found the following structure in the documentation:

proc ds2;
data;
  declare double y;
  method run();
    y=cdf('TWEEDIE', 0.8, 5);
  end;
enddata;

run;
quit;

It ran in SAS UE

 

Art, CEO, AnalystFinder.com

 

Rick_SAS
SAS Super FREQ

You can run the CDF function in the DATA step. No need to use DS2.

 

data Tweedie;
do x = 0 to 3 by 0.05;
   y=cdf('TWEEDIE', x, 5);
   output;
end;
run;

title "CDF of the Tweedie(5) Distribution";
proc sgplot data=Tweedie;
   series x=x y=y;
run;

 

nikolasfilbert
Fluorite | Level 6
Thank you for your response! But if I want to input x from a column of a table, how should I write it?
Rick_SAS
SAS Super FREQ

If the SAS data set 'HAVE' contains a variable named 'X' that contains the points at which you want to evaluate the CDF, you can say

 

data Tweedie;
set HAVE;
y=cdf('Tweedie', X, 5);
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 1204 views
  • 1 like
  • 4 in conversation