BookmarkSubscribeRSS Feed
tmorr
Fluorite | Level 6

hello, so i try to create the random dataset, i have an exponential distribution with parameter lambda is 1/(12*10^6) and the seed 1999 and i try to generate the 1000 revenues and retain the integer portion for establishments. here is the code below:

Screen Shot 2022-01-27 at 6.59.11 PM.png

1 REPLY 1
ballardw
Super User

Your data step as shown should show several errors. First, exponentiation in SAS is not done with an ^. To make 10 to the 6th power use **  or 10**6

Your log should show something like:

547  data temp;
548     do lambda = 1/(12*10^6);
                             -
                             22
                             76
ERROR 22-322: Syntax error, expecting one of the following: <, <=, =, >, >=, EQ, GE, GT, LE, LT,
              NE, NG, NL, ^=, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

549        do i=1 to 1000;
550           x=ranexp(1999)/lambda;
551           output;
552        end;
553  run;

Fixing the exponent is not sufficient:

554  data temp;
555     do lambda = 1/(12*10**6);
556        do i=1 to 1000;
557           x=ranexp(1999)/lambda;
558           output;
559        end;
560  run;

560  run;
        -
        117
ERROR 117-185: There was 1 unclosed DO block.

You do not want the DO in front of the Lambda:

561  data temp;
562        lambda = 1/(12*10**6);
563        do i=1 to 1000;
564           x=ranexp(1999)/lambda;
565           output;
566        end;
567  run;

NOTE: The data set WORK.TEMP has 1000 observations and 3 variables.

Since your data set did not complete successfully the Proc SGPLOT might be using an older data set named Temp.

The set you make would not have a variable CLOSE so the HISTOGRAM statement is in error.

569  Proc sgplot data=temp;
570     histogram close;
ERROR: Variable CLOSE not found.
571  run;

I would expect to see: Histogram X;

 

READ your log. Click on the Log tab. See the errors.

You should be able to copy text from the log and paste that into the forum to ask questions about things that do not work. Open a text box, such as my log entries above, with the </> icon above the message window on the forum and paste the copied text.

 

I do not see any attempt to get an "integer portion". I would expect to see one of the functions such as ROUND, FLOOR, CEIL to reduce X to an integer.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 487 views
  • 2 likes
  • 2 in conversation