BookmarkSubscribeRSS Feed
thanoon
Calcite | Level 5

hi all

anyone help me to simulate different sample size by using sas program above to get on two different mvordinal matrix.

thanks in advance

Rick_SAS
SAS Super FREQ

SampleSize = 800;

Y = RandMVOrdinal(SampleSize, P, Delta);

thanoon
Calcite | Level 5

thanks alot dr. rick just i want to know you mean samplesize for two different samples 1=400,2=400 because i dont get on two sample size and i can not apply this command with loop approach and my program will be as below:

%include "RandMVOrd.sas";

proc iml;

load module=_all_;                     /* load the modules */

    /* P1    P2     P3       p4     p5      p6       p7      p8     p9      p10 */

P = {0.35 0.50 0.20 0.10   0.10   0.30    0.20 0.25 0.15 0.20,

     0.30 0.10 0.20 0.30   0.20   0.20    0.40 0.05 0.45    0.10,

     0.15 0.20    0.35 0.25   0.50   0.20    0.25 0.55 0.10 0.10,

     0.20 0.20 0.25 0.35   0.20   0.30    0.15 0.15 0.30    0.60};

/* expected values and variance for each ordinal variable */

Expected = Mean(P) // Var(P);

varNames = "X1":"X10";

print Expected[r={"Mean" "Var"} c=varNames];

/* test the RandMVOrd function */

Delta = {1  0.45 0.4   0.35 0.3    0.25 0.2    0.15 0.1    0.05,

        0.45 1 0.45 0.4    0.35 0.3    0.25 0.2    0.15 0.1,

        0.4  0.45 1   0.45    0.4    0.35 0.3    0.25 0.2    0.15,

        0.35  0.4 0.45 1    0.45 0.4    0.35 0.3    0.25 0.2,

        0.3  0.35 0.4   0.45     1    0.45 0.4    0.35 0.3    0.25,

        0.25  0.3 0.35 0.4    0.45   1    0.45 0.4    0.35 0.3,

        0.2  0.25 0.3   0.35    0.4    0.45 1    0.45 0.4    0.35,

        0.15  0.2 0.25 0.3   0.35 0.4    0.45   1    0.45 0.4,

        0.1  0.15 0.2   0.25   0.3    0.35 0.4    0.45   1    0.45,

        0.05  0.1 0.15 0.2 0.25 0.3    0.35 0.4   0.45     1};

/* loop approach */

Samplesize = 800;

call randseed(54321);

   X = RandMVOrdinal(samplesize, P, Delta);

/* print results */

c=varNames;

create MVO from X[colname=c];  append from X;  close MVO;

quit;

thanks

thanoon
Calcite | Level 5

dear dr.

i still have some errors after putting the previous code can you correct it to me please

proc iml;

load module=_all_;                     /* load the modules */

    /* P1    P2     P3       p4     p5      p6       p7      p8     p9      p10 */

P = {0.35 0.50 0.20 0.10   0.10   0.30    0.20 0.25 0.15 0.20,

     0.30 0.10 0.20 0.30   0.20   0.20    0.40 0.05 0.45    0.10,

     0.15 0.20    0.35 0.25   0.50   0.20    0.25 0.55 0.10 0.10,

     0.20 0.20 0.25 0.35   0.20   0.30    0.15 0.15 0.30    0.60};

/* expected values and variance for each ordinal variable */

Expected = Mean(P) // Var(P);

varNames = "X1":"X10";

print Expected[r={"Mean" "Var"} c=varNames];

/* test the RandMVOrd function */

Delta = {1  0.45 0.4   0.35 0.3    0.25 0.2    0.15 0.1    0.05,

        0.45 1 0.45 0.4    0.35 0.3    0.25 0.2    0.15 0.1,

        0.4  0.45 1   0.45    0.4    0.35 0.3    0.25 0.2    0.15,

        0.35  0.4 0.45 1    0.45 0.4    0.35 0.3    0.25 0.2,

        0.3  0.35 0.4   0.45     1    0.45 0.4    0.35 0.3    0.25,

        0.25  0.3 0.35 0.4    0.45   1    0.45 0.4    0.35 0.3,

        0.2  0.25 0.3   0.35    0.4    0.45 1    0.45 0.4    0.35,

        0.15  0.2 0.25 0.3   0.35 0.4    0.45   1    0.45 0.4,

        0.1  0.15 0.2   0.25   0.3    0.35 0.4    0.45   1    0.45,

        0.05  0.1 0.15 0.2 0.25 0.3    0.35 0.4   0.45     1};

/* loop approach */

NumSamples = 2;

call randseed(54321);

do i = 1 to NumSamples;

   X = RandMVOrdinal(500, P, Delta);

  /* do something with each sample  */

   end;

/* print results */

c=varNames;

create MVO from X[colname=c];  append from X;  close MVO;

quit;

many thanks

SteveDenham
Jade | Level 19

Without the log, it is impossible to diagnose errors.  With the log, you should be able to identify critical points, and suggest yourself what might be done.  That would be much more likely to draw helpful responses than just firing code at the forum, and saying "I have errors."

Steve Denham

thanoon
Calcite | Level 5

thanks alot Mr. Steve

this is the log

1                                                          The SAS System                            17:52 Monday, February 24, 2014

1          ;*';*";*/;quit;run;

2          OPTIONS PAGENO=MIN;

3          %LET _CLIENTTASKLABEL='222222222 after intiqam multi samples';

4          %LET _CLIENTPROJECTPATH='';

5          %LET _CLIENTPROJECTNAME='';

6          %LET _SASPROGRAMFILE='F:\sas simulation final\sas cods program\222222222 after intiqam multi samples.sas';

7         

8          ODS _ALL_ CLOSE;

9          OPTIONS DEV=ACTIVEX;

10         GOPTIONS XPIXELS=0 YPIXELS=0;

11         FILENAME EGSR TEMP;

12         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR STYLE=HtmlBlue

12       ! STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/5.1/Styles/HtmlBlue.css") NOGTITLE NOGFOOTNOTE

12       ! GPATH=&sasworklocation ENCODING=UTF8 options(rolap="on");

NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR

13        

14         GOPTIONS ACCESSIBLE;

15         proc iml;

WARNING: The SAS/IML product with which IML (2) is associated will be expiring soon, and is currently in warning mode to indicate

         this upcoming expiration. Please run PROC SETINIT to obtain more information on your warning period.

NOTE: IML Ready

16         load module=_all_;

NOTE: Opening storage library WORK.IMLSTOR

16       !                                        /* load the modules */

17             /* P1    P2     P3       p4     p5      p6       p7      p8     p9      p10 */

18         P = {0.35 0.50 0.20 0.10   0.10   0.30    0.20 0.25 0.15 0.20,

19              0.30 0.10 0.20 0.30   0.20   0.20    0.40 0.05 0.45    0.10,

20              0.15 0.20    0.35 0.25   0.50   0.20    0.25 0.55 0.10 0.10,

21              0.20 0.20 0.25 0.35   0.20   0.30    0.15 0.15 0.30    0.60};

22        

23        

24         /* expected values and variance for each ordinal variable */

25         Expected = Mean(P) // Var(P);

26         varNames = "X1":"X10";

27         print Expected[r={"Mean" "Var"} c=varNames];

28         /* test the RandMVOrd function */

29         Delta = {1  0.45 0.4   0.35 0.3    0.25 0.2    0.15 0.1    0.05,

30                 0.45 1 0.45 0.4    0.35 0.3    0.25 0.2    0.15 0.1,

31                 0.4  0.45 1   0.45    0.4    0.35 0.3    0.25 0.2    0.15,

32                 0.35  0.4 0.45 1    0.45 0.4    0.35 0.3    0.25 0.2,

33                 0.3  0.35 0.4   0.45     1    0.45 0.4    0.35 0.3    0.25,

34                 0.25  0.3 0.35 0.4    0.45   1    0.45 0.4    0.35 0.3,

35                 0.2  0.25 0.3   0.35    0.4    0.45 1    0.45 0.4    0.35,

36                 0.15  0.2 0.25 0.3   0.35 0.4    0.45   1    0.45 0.4,

37                 0.1  0.15 0.2   0.25   0.3    0.35 0.4    0.45   1    0.45,

38                 0.05  0.1 0.15 0.2 0.25 0.3    0.35 0.4   0.45     1};

39         /* loop approach */

40         NumSamples = 10;

41         call randseed(54321);

42         do i = 1 to NumSamples;

43            X = RandMVOrdinal(1000, P, Delta);

44           /* do something with each sample  */

45            end;

ERROR: Invocation of unresolved module RANDMVORDINAL.

statement : ASSIGN at line 43 column 4

46         /* print results */

47         c=varNames;

2                                                          The SAS System                            17:52 Monday, February 24, 2014

48         create MVO from X[colname=c];

ERROR: Matrix X has not been set to a value.

statement : CREATE at line 48 column 1

48       !                                append from X;

ERROR: No data set is currently open for output.

statement : APPEND at line 48 column 32

48       !                                                close MVO;

NOTE: Cannot close WORK.MVO; it is not open.

49         quit;

NOTE: Exiting IML.

NOTE: Storage library WORK.IMLSTOR closed.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IML used (Total process time):

      real time           0.90 seconds

      cpu time            0.04 seconds

     

50        

51         GOPTIONS NOACCESSIBLE;

52         %LET _CLIENTTASKLABEL=;

53         %LET _CLIENTPROJECTPATH=;

54         %LET _CLIENTPROJECTNAME=;

55         %LET _SASPROGRAMFILE=;

56        

57         ;*';*";*/;quit;run;

58         ODS _ALL_ CLOSE;

59        

60        

61         QUIT; RUN;

62        

SteveDenham
Jade | Level 19

The first thing I would check is whether or not the module RANDMVORDINAL is correctly saved in IMLSTOR.  The error statement implies that it is not present at execution, which in turn implies that it is not in the store.  Go back to where you created the module and make sure that there are no errors associated with it, AND that it has been stored correctly.

Steve Denham

Message was edited by: Steve Denham

Rick_SAS
SAS Super FREQ

You can use

SHOW MODULES;

to see what modules are loaded.

thanoon
Calcite | Level 5

thanks alot doctor rick

i wrote this command SHOW MODULES in sas program and got on  same results but i think the problem in loop command.

1                                                          The SAS System                         16:57 Wednesday, February 26, 2014

1          ;*';*";*/;quit;run;

2          OPTIONS PAGENO=MIN;

3          %LET _CLIENTTASKLABEL='222222222 after intiqam multi samples';

4          %LET _CLIENTPROJECTPATH='';

5          %LET _CLIENTPROJECTNAME='';

6          %LET _SASPROGRAMFILE='F:\sas simulation final\sas cods program\222222222 after intiqam multi samples.sas';

7         

8          ODS _ALL_ CLOSE;

9          OPTIONS DEV=ACTIVEX;

10         GOPTIONS XPIXELS=0 YPIXELS=0;

11         FILENAME EGSR TEMP;

12         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR STYLE=HtmlBlue

12       ! STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/5.1/Styles/HtmlBlue.css") NOGTITLE NOGFOOTNOTE

12       ! GPATH=&sasworklocation ENCODING=UTF8 options(rolap="on");

NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR

13        

14         GOPTIONS ACCESSIBLE;

15         proc iml;

NOTE: IML Ready

16         SHOW MODULES;

NOTE: No modules are currently defined.

17        

18             /* P1    P2     P3       p4     p5      p6       p7      p8     p9      p10 */

19         P = {0.35 0.50 0.20 0.10   0.10   0.30    0.20 0.25 0.15 0.20,

20              0.30 0.10 0.20 0.30   0.20   0.20    0.40 0.05 0.45    0.10,

21              0.15 0.20    0.35 0.25   0.50   0.20    0.25 0.55 0.10 0.10,

22              0.20 0.20 0.25 0.35   0.20   0.30    0.15 0.15 0.30    0.60};

23        

24        

25         /* expected values and variance for each ordinal variable */

26         Expected = Mean(P) // Var(P);

27         varNames = "X1":"X10";

28         print Expected[r={"Mean" "Var"} c=varNames];

29         /* test the RandMVOrd function */

30         Delta = {1  0.45 0.4   0.35 0.3    0.25 0.2    0.15 0.1    0.05,

31                 0.45 1 0.45 0.4    0.35 0.3    0.25 0.2    0.15 0.1,

32                 0.4  0.45 1   0.45    0.4    0.35 0.3    0.25 0.2    0.15,

33                 0.35  0.4 0.45 1    0.45 0.4    0.35 0.3    0.25 0.2,

34                 0.3  0.35 0.4   0.45     1    0.45 0.4    0.35 0.3    0.25,

35                 0.25  0.3 0.35 0.4    0.45   1    0.45 0.4    0.35 0.3,

36                 0.2  0.25 0.3   0.35    0.4    0.45 1    0.45 0.4    0.35,

37                 0.15  0.2 0.25 0.3   0.35 0.4    0.45   1    0.45 0.4,

38                 0.1  0.15 0.2   0.25   0.3    0.35 0.4    0.45   1    0.45,

39                 0.05  0.1 0.15 0.2 0.25 0.3    0.35 0.4   0.45     1};

40         /* loop approach */

41         NumSamples = 10;

42         call randseed(54321);

43         do i = 1 to NumSamples;

44            X = RandMVOrdinal(1000, P, Delta);

45           /* do something with each sample  */

46            end;

ERROR: Invocation of unresolved module RANDMVORDINAL.

statement : ASSIGN at line 44 column 4

47         /* print results */

48         c=varNames;

49         create MVO from X[colname=c];

ERROR: Matrix X has not been set to a value.

2                                                          The SAS System                         16:57 Wednesday, February 26, 2014

statement : CREATE at line 49 column 1

49       !                                append from X;

ERROR: No data set is currently open for output.

statement : APPEND at line 49 column 32

49       !                                                close MVO;

NOTE: Cannot close WORK.MVO; it is not open.

50         quit;

NOTE: Exiting IML.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IML used (Total process time):

      real time           0.27 seconds

      cpu time            0.03 seconds

     

51        

52         GOPTIONS NOACCESSIBLE;

53         %LET _CLIENTTASKLABEL=;

54         %LET _CLIENTPROJECTPATH=;

55         %LET _CLIENTPROJECTNAME=;

56         %LET _SASPROGRAMFILE=;

57        

58         ;*';*";*/;quit;run;

59         ODS _ALL_ CLOSE;

60        

61        

62         QUIT; RUN;

63        

SteveDenham
Jade | Level 19

That indicates that it is not in IMLSTOR. Go back to where you created the module RANDMVORDINAL and make sure that there are no errors associated with it, AND that it has been stored correctly.

Steve Denham

thanoon
Calcite | Level 5

dear mr. denham

i dont find where is the error in sas program.

SteveDenham
Jade | Level 19

Since RANDMVORDINAL is not in IMLSTOR, either it was created and not stored, or not created.  You have to address this fact before any of the code here will run.

Steve Denham

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!
Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 26 replies
  • 2331 views
  • 0 likes
  • 3 in conversation