Statistical programming, matrix languages, and more

Elasticities in Almost Idela demand system

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Elasticities in Almost Idela demand system

Dear All

 

I have some troubles in calculating price elasticities in an  AIDS model (linear) . I am following the example "Calculating Elasticities in  an Almost Ideal Demand System). However, after runing Proc IMl, when the vector of budget share is to be created, the following message  appears; ERROR 180-322: Statement is not valid or it is used out of proper order.

I have checked  for semicolon and other possible misprint.

 

Thank you

MB


Accepted Solutions
Solution
‎06-30-2017 03:48 PM
SAS Super FREQ
Posts: 3,754

Re: Elasticities in Almost Idela demand system

You have two vertical concatenation operators in a row. Delete the trailing operator after WSUB_ITAHOVEN:

WSUB_ITAHOVEN//
//WITADAIRY_SUB

 

And to anticipate your next question, you also have an error in the horizontal concatenation:

U12| |U13||U14| U15

should be

U12||U13||U14||U15

 

You have dozens of similar errors, so please fix them all.

 

If I may make a suggestion, you might want to read multiple variables into a single matrix. It will make the code much shorter and simpler:

 

read all var ("B1":"B15") into B;
read all var ("C1":"C15") into C;
read all var ("U1":"U15") into U;
...
read all var {S11 S12 S13 S14 S15 S16 S17 S18 S19 S111 S112 S113 S114 S115} into S;
...

gij= B // C // U // ... // O;

 

If you are not familiar with the index creation operator (Smiley Happy, see the article "How to create column names for matrices."

View solution in original post


All Replies
SAS Super FREQ
Posts: 3,754

Re: Elasticities in Almost Idela demand system

You are going to need to post your program or SAS log. There is no way to help without it.

Also please state the version of SAS/IML that you are using.

New Contributor
Posts: 4

Re: Elasticities in Almost Idela demand system

Thank yuo.

 

Here is the log. The SAS version is 9.4. I suppose the IML version varies accordingly

 

Regards

 

MB

 

 

NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M0)
      Licensed to UNIVERSITA  CATTOLICA DEL SACRO CUORE, Site 70123393.
NOTE: This session is executing on the X64_7PRO  platform.

NOTE: Updated analytical products:

      SAS/STAT 12.3 (maintenance)
      SAS/ETS 12.3 (maintenance)
      SAS/OR 12.3 (maintenance)
      SAS/IML 12.3 (maintenance)
      SAS/QC 12.3 (maintenance)

NOTE: Additional host information:

 X64_7PRO WIN 6.1.7601 Service Pack 1 Workstation

NOTE: SAS initialization used:
      real time           2.39 seconds
      cpu time            1.26 seconds

NOTE: Writing HTML Body file: sashtml.htm
1    Proc model data=bau.consumo3;
2
3    witabread_less= B0+B1*LP_ITABREAD_LESS+ B2*LP_ITACHEESE_LESS + B3*LP_ITADAIRYUH_LESS +
3  ! B4*LP_ITAFORNO_LESS + B5*LP_ITAPASTA_LESS + B6*LP_LATTE_LESS + B7*LP_PFRESCA_LESS +
3  ! B8*LP_SUBITABREAD + B9*LP_SUBITACHEESE + B10*LP_SUBITADAIRYUHT + B11*LP_SUBITAFORNO +
3  ! B12*LP_SUBITALATTE + B13*LP_SUBITAPASTA + B14*LP_SUBITAPFRESCA + B15*LP_OTHERPLUS + B16*LREXP
3  ! ;
4
5
6    WITACHEESE_LESS = C0+C1*LP_ITABREAD_LESS+ C2*LP_ITACHEESE_LESS + C3*LP_ITADAIRYUH_LESS +
6  ! C4*LP_ITAFORNO_LESS + C5*LP_ITAPASTA_LESS + C6*LP_LATTE_LESS + C7*LP_PFRESCA_LESS +
6  ! C8*LP_SUBITABREAD + C9*LP_SUBITACHEESE + C10*LP_SUBITADAIRYUHT + C11*LP_SUBITAFORNO +
6  ! C12*LP_SUBITALATTE + C13*LP_SUBITAPASTA + C14*LP_SUBITAPFRESCA + C15*LP_OTHERPLUS+C16*LREXP ;
7
8
9
10   WITADAIRY_UHTLESS = U0+U1*LP_ITABREAD_LESS+ U2*LP_ITACHEESE_LESS + U3*LP_ITADAIRYUH_LESS +
10 ! U4*LP_ITAFORNO_LESS + U5*LP_ITAPASTA_LESS + U6*LP_LATTE_LESS + U7*LP_PFRESCA_LESS +
10 ! U8*LP_SUBITABREAD + U9*LP_SUBITACHEESE + U10*LP_SUBITADAIRYUHT + U11*LP_SUBITAFORNO +
10 ! U12*LP_SUBITALATTE + U13*LP_SUBITAPASTA + U14*LP_SUBITAPFRESCA + U15*LP_OTHERPLUS+ U16*LREXP
10 ! ;
11
12
13
14   WITAHOVEN_LESS = H0+H1*LP_ITABREAD_LESS+ H2*LP_ITACHEESE_LESS + H3*LP_ITADAIRYUH_LESS +
14 ! H4*LP_ITAFORNO_LESS + H5*LP_ITAPASTA_LESS + H6*LP_LATTE_LESS + H7*LP_PFRESCA_LESS +
14 ! H8*LP_SUBITABREAD + H9*LP_SUBITACHEESE + H10*LP_SUBITADAIRYUHT + H11*LP_SUBITAFORNO +
14 ! H12*LP_SUBITALATTE + H13*LP_SUBITAPASTA + H14*LP_SUBITAPFRESCA + H15*LP_OTHERPLUS+ H16*LREXP
14 ! ;
15
16
17   WITA_PASTALESS = P0+P1*LP_ITABREAD_LESS+ P2*LP_ITACHEESE_LESS + P3*LP_ITADAIRYUH_LESS +
17 ! P4*LP_ITAFORNO_LESS + P5*LP_ITAPASTA_LESS + P6*LP_LATTE_LESS + P7*LP_PFRESCA_LESS +
17 ! P8*LP_SUBITABREAD + P9*LP_SUBITACHEESE + P10*LP_SUBITADAIRYUHT + P11*LP_SUBITAFORNO +
17 ! P12*LP_SUBITALATTE + P13*LP_SUBITAPASTA + P14*LP_SUBITAPFRESCA + P15*LP_OTHERPLUS + P16*LREXP
17 ! ;
18
19
20
21   WITADAIRY_LESS = D0+D1*LP_ITABREAD_LESS+ D2*LP_ITACHEESE_LESS + D3*LP_ITADAIRYUH_LESS +
21 ! D4*LP_ITAFORNO_LESS + D5*LP_ITAPASTA_LESS + D6*LP_LATTE_LESS + D7*LP_PFRESCA_LESS +
21 ! D8*LP_SUBITABREAD + D9*LP_SUBITACHEESE + D10*LP_SUBITADAIRYUHT + D11*LP_SUBITAFORNO +
21 ! D12*LP_SUBITALATTE + D13*LP_SUBITAPASTA + D14*LP_SUBITAPFRESCA + D15*LP_OTHERPLUS+ D16*LREXP
21 ! ;
22
23
24   WITAFRESHP_LESS =F0+ F1*LP_ITABREAD_LESS+ F2*LP_ITACHEESE_LESS + F3*LP_ITADAIRYUH_LESS +
24 ! F4*LP_ITAFORNO_LESS + F5*LP_ITAPASTA_LESS + F6*LP_LATTE_LESS + F7*LP_PFRESCA_LESS +
24 ! F8*LP_SUBITABREAD + F9*LP_SUBITACHEESE + F10*LP_SUBITADAIRYUHT + F11*LP_SUBITAFORNO +
24 ! F12*LP_SUBITALATTE + F13*LP_SUBITAPASTA + F14*LP_SUBITAPFRESCA + F15*LP_OTHERPLUS+F16*LREXP ;
25
26
27
28   WITABREAD_SUB = S10+S11*LP_ITABREAD_LESS+ S12*LP_ITACHEESE_LESS + S13*LP_ITADAIRYUH_LESS +
28 ! S14*LP_ITAFORNO_LESS + S15*LP_ITAPASTA_LESS + S16*LP_LATTE_LESS + S17*LP_PFRESCA_LESS +
28 ! S18*LP_SUBITABREAD + S19*LP_SUBITACHEESE + S110*LP_SUBITADAIRYUHT + S111*LP_SUBITAFORNO +
28 ! S112*LP_SUBITALATTE + S113*LP_SUBITAPASTA + S114*LP_SUBITAPFRESCA +
28 ! S115*LP_OTHERPLUS+S116*LREXP ;
29
30
31
32   WSUB_ITACHEESE= S30+S31*LP_ITABREAD_LESS+ S32*LP_ITACHEESE_LESS + S33*LP_ITADAIRYUH_LESS +
32 ! S34*LP_ITAFORNO_LESS + S35*LP_ITAPASTA_LESS + S36*LP_LATTE_LESS + S37*LP_PFRESCA_LESS +
32 ! S38*LP_SUBITABREAD + S39*LP_SUBITACHEESE + S310*LP_SUBITADAIRYUHT + S311*LP_SUBITAFORNO +
32 ! S312*LP_SUBITALATTE + S313*LP_SUBITAPASTA + S314*LP_SUBITAPFRESCA + S315*LP_OTHERPLUS +
32 ! S316*LREXP;
33
34
35
36
37   WSUB_ITAHOVEN =S50+S51*LP_ITABREAD_LESS+S52*LP_ITACHEESE_LESS + S53*LP_ITADAIRYUH_LESS +
37 ! S54*LP_ITAFORNO_LESS + S55*LP_ITAPASTA_LESS + S56*LP_LATTE_LESS + S57*LP_PFRESCA_LESS +
37 ! S58*LP_SUBITABREAD + S59*LP_SUBITACHEESE + S510*LP_SUBITADAIRYUHT + S511*LP_SUBITAFORNO +
37 ! S512*LP_SUBITALATTE + S513*LP_SUBITAPASTA + S514*LP_SUBITAPFRESCA + S515*LP_OTHERPLUS+
37 ! S516*LREXP ;
38
39
40   WITADAIRY_SUB=S20+ S21*LP_ITABREAD_LESS+ S22*LP_ITACHEESE_LESS + S23*LP_ITADAIRYUH_LESS +
40 ! S24*LP_ITAFORNO_LESS + S25*LP_ITAPASTA_LESS + S26*LP_LATTE_LESS + S27*LP_PFRESCA_LESS +
40 ! S28*LP_SUBITABREAD + S29*LP_SUBITACHEESE + S210*LP_SUBITADAIRYUHT + S211*LP_SUBITAFORNO +
40 ! S212*LP_SUBITALATTE + S213*LP_SUBITAPASTA + S214*LP_SUBITAPFRESCA + S215*LP_OTHERPLUS+
40 ! S216*LREXP ;
41
42   WSUB_ITAPASTA = S60+S61*LP_ITABREAD_LESS+ S62*LP_ITACHEESE_LESS + S63*LP_ITADAIRYUH_LESS +
42 ! S64*LP_ITAFORNO_LESS + S65*LP_ITAPASTA_LESS + S66*LP_LATTE_LESS + S67*LP_PFRESCA_LESS +
42 ! S68*LP_SUBITABREAD + S69*LP_SUBITACHEESE + S610*LP_SUBITADAIRYUHT + S611*LP_SUBITAFORNO +
42 ! S612*LP_SUBITALATTE + S613*LP_SUBITAPASTA + S614*LP_SUBITAPFRESCA + S615*LP_OTHERPLUS+
42 ! S616*LREXP ;
43
44
45
46   WSUB_ITAFRESHP = S40+S41*LP_ITABREAD_LESS+ S42*LP_ITACHEESE_LESS + S43*LP_ITADAIRYUH_LESS +
46 ! S44*LP_ITAFORNO_LESS + S45*LP_ITAPASTA_LESS + S46*LP_LATTE_LESS + S47*LP_PFRESCA_LESS +
46 ! S48*LP_SUBITABREAD + S49*LP_SUBITACHEESE + S410*LP_SUBITADAIRYUHT + S411*LP_SUBITAFORNO +
46 ! S412*LP_SUBITALATTE + S413*LP_SUBITAPASTA + S414*LP_SUBITAPFRESCA + S415*LP_OTHERPLUS +
46 ! S416*LREXP;
47
48   WOTHERPLUS = O0+O1*LP_ITABREAD_LESS+ O2*LP_ITACHEESE_LESS + O3*LP_ITADAIRYUH_LESS +
48 ! O4*LP_ITAFORNO_LESS + O5*LP_ITAPASTA_LESS + O6*LP_LATTE_LESS + O7*LP_PFRESCA_LESS +
48 ! O8*LP_SUBITABREAD + O9*LP_SUBITACHEESE + O10*LP_SUBITADAIRYUHT + O11*LP_SUBITAFORNO +
48 ! O12*LP_SUBITALATTE + O13*LP_SUBITAPASTA + O14*LP_SUBITAPFRESCA + O15*LP_OTHERPLUS+ O16*LREXP;
49
50
51

52   FIT witabread_less WITACHEESE_LESS  WITADAIRY_UHTLESS WITAHOVEN_LESS WITA_PASTALESS
52 ! WITADAIRY_LESS WITAFRESHP_LESS WITABREAD_SUB WSUB_ITACHEESE WSUB_ITAHOVEN WITADAIRY_SUB
52 ! WSUB_ITAPASTA WSUB_ITAFRESHP WOTHERPLUS /ITSUR NESTIT OUTS=REST  OUTEST=BAU.CONSUMO5
52 ! OUT=RESID2 CONVERGE=.00001 MAXIT=1000;
53   PARMS B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16
54
55   C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16
56
57   U0 U1 U2 U3 U4 U5 U6 U7 U8 U9 U10 U11 U12 U13 U14 U15 U16
58   H0 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16
59
60   P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16
61   D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16
62   F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16
63   S10 S11 S12 S13 S14 S15 S16 S17 S18 S19 S110 S111 S112 S113 S114 S115 S116
64   S30 S31 S32 S33 S34 S35 S36 S37 S38 S39 S310 S311 S312 S313 S314 S315 S316
65   S50 S51 S52 S53 S54 S55 S56 S57 S58 S59 S510 S511 S512 S513 S514 S515 S516
66   S20 S21 S22 S23 S24 S25 S26 S27 S28 S29 S210 S211 S212 S213 S214 S215 S216
67   S60 S61 S62 S63 S64 S65 S66 S67 S68 S69 S610 S611 S612 S613 S614 S615 S616
68   S40 S41 S42 S43 S44 S45 S46 S47 S48 S49 S410 S411 S412 S413 S414 S415 S416
69   O0 O1 O2 O3 O4 O5 O6 O7 O8 O9 O10 O11 O12 O13 O14 O15 O16;
70   run;

NOTE: At ITSUR Iteration 2 CONVERGE=0.00001 Criteria Met.
NOTE: The data set WORK.RESID2 has 60 observations and 33 variables.
NOTE: The data set BAU.CONSUMO5 has 1 observations and 242 variables.
NOTE: The data set WORK.REST has 14 observations and 17 variables.

NOTE: PROCEDURE MODEL used (Total process time):
      real time           1:17.70
      cpu time            7.36 seconds


71   Proc means data=bau.consumo3 noprint;
72   Var;
73
74   OUTPUT OUT=MEANW  MEAN= witabread_less WITACHEESE_LESS  WITADAIRY_UHTLESS WITAHOVEN_LESS
74 ! WITA_PASTALESS WITADAIRY_LESS WITAFRESHP_LESS WITABREAD_SUB WSUB_ITACHEESE  WSUB_ITAHOVEN
74 ! WITADAIRY_SUB WSUB_ITAPASTA WSUB_ITAFRESHP WOTHERPLUS LREXP;
75   run;

NOTE: There were 60 observations read from the data set BAU.CONSUMO3.
NOTE: The data set WORK.MEANW has 1 observations and 17 variables.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.11 seconds
      cpu time            0.09 seconds


OLE Error: 80040064.  Struttura FORMATETC non valida.
76   PROC IML;
NOTE: IML Ready
77   use bau.consumo5;
78   read all var { B1 B2 B3 B4 B5 B6 B7 B8 B9 B11 B12 B13 B14 B15 B16
79   C1 C2 C3 C4 C5 C6 C7 C8 C9 C11 C12 C13 C14 C15 C16
80
81   U1 U2 U3 U4 U5 U6 U7 U8 U9 U11 U12 U13 U14 U15 U16
82   H1 H2 H3 H4 H5 H6 H7 H8 H9 H11 H12 H13 H14 H15 H16
83
84   P1 P2 P3 P4 P5 P6 P7 P8 P9 P11 P12 P13 P14 P15 P16
85   D1 D2 D3 D4 D5 D6 D7 D8 D9 D11 D12 D13 D14 D15 D16
86   F1 F2 F3 F4 F5 F6 F7 F8 F9 F11 F12 F13 F14 F15 F16
87   S11 S12 S13 S14 S15 S16 S17 S18 S19 S111 S112 S113 S114 S115 S116
88   S31 S32 S33 S34 S35 S36 S37 S38 S39 S311 S312 S313 S314 S315 S316
89   S51 S52 S53 S54 S55 S56 S57 S58 S59 S511 S512 S513 S514 S515 S516
90   S21 S22 S23 S24 S25 S26 S27 S28 S29 S211 S212 S213 S214 S215 S216
91   S61 S62 S63 S64 S65 S66 S67 S68 S69 S611 S612 S613 S614 S615 S616
92   S41 S42 S43 S44 S45 S46 S47 S48 S49 S411 S412 S413 S414 S415 S416
93   O1 O2 O3 O4 O5 O6 O7 O8 O9 O11 O12 O13 O14 O15 O16};
94   close bau.consumo5;
95
96   /*READ MEANS*/
97
98   use meanw;
99   READ ALL VAR{ witabread_less WITACHEESE_LESS  WITADAIRY_UHTLESS WITAHOVEN_LESS WITA_PASTALESS
99 !  WITADAIRY_LESS WITAFRESHP_LESS WITABREAD_SUB WSUB_ITACHEESE  WSUB_ITAHOVEN WITADAIRY_SUB
99 ! WSUB_ITAPASTA WSUB_ITAFRESHP WOTHERPLUS LREXP };
100
101
102  close meanw;
103  /*BUDGET SHARE VECTOR*/
104  W=witabread_less // WITACHEESE_LESS // WITADAIRY_UHTLESS //WITAHOVEN_LESS//WITA_PASTALESS
104! //WITADAIRY_LESS //WITAFRESHP_LESS //WITABREAD_SUB //WSUB_ITACHEESE //WSUB_ITAHOVEN//
104! //WITADAIRY_SUB//WSUB_ITAPASTA  //WSUB_ITAFRESHP// WOTHERPLUS;
     --
     22
     76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
              a numeric constant, a datetime constant, a missing value, +.

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

105  /*GAMMA  IJ MATRIX */
106  /* TOLTO  (16) PERCHE’ E’ SU REDDITO tolta costante e numero 10*/
107  gij=(B1||B2||B3||B4||B5||B6||B7||B8||B9||B11||B12||B13||B14||B15)//
108
109  (C1||C2||C3||C4||C5||C6||C7||C8||C9||C11||C12||C13||C14||C15)//
110
111  (U1||U2||U3||U4||U5||U6||U7||U8||U9||U11||U12| |U13||U14| U15)//
                                                    -
                                                    22
                                                    76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
              a numeric constant, a datetime constant, a missing value, +.

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

112  (H1||H2||H3||H4||H5||H6||H7||H8| |H9||H11| |H12||H13||H14||H15|)//
113
114  (P1||P2||P3||P4||P5||P6||P7||P8||P9||P11||P12||P13||P14||P15)//
115  (D1||D2||D3||D4||D5||D6||D7||D8||D9||D11||D12||D13||D14||D15)//
116  (F1||F2||F3||F4||F5||F6||F7||F8||F9||F11||F12||F13||F14||F15)//
117  (S11||S12||S13||S14||S15||S16||S17||S18||S19||S111||S112||S113| |S114||S115)//
118  (S30||S31||S32||S33||S34||S35||S36||S37||S38||S39||S310||S311||S312||S313| |S314||S315)//
119  (S51||S52||S53||S54||S55||S56||S57||S58||S59||S511||S512||S513| |S514||S515)//
120  (S21||S22||S23||S24||S25||S26||S27||S28||S29||S210||S211||S212||S213| |S214||S215)//
121  (S61||S62||S63||S64||S65||S66||S67||S68||S69||S611||S612||S613| |S614||S615)//
122  (S41||S42|S43||S44||S45||S46||S47||S48||S49||S410||S411||S412||S413||S414| |S415)//
123  (O1||O2||O3||O4||O5||O6||O7||O8||O9||O11| |O12||O13||O14||O15);
124  /* SUBITADAIRYUHT PARAMETERS*/
125  /* Bisognerebbe mettere una equazione per W SUBITADAIRYUHT
126  =0- B16-C16 U16-H16-P16-D16-F16-S116-S316-S516-S216-S616-   S416-O16;*/
127
128  /*CALCULATE  EACH ELEMENT OF THE ELASTICITY MATRIX*/
129  nk=ncol(gi);
130  mi=-1#I(nk);
ERROR: (execution) Invalid operand to operation.

 operation : I at line 130 column 8
 operands  : nk

nk      1 row       1 col     (numeric)

         0

 statement : ASSIGN at line 130 column 1
131  ff2=j(nk,nk,0);
ERROR: (execution) Invalid operand to operation.

 operation : J at line 131 column 6
 operands  : nk, nk, *LIT1004

nk      1 row       1 col     (numeric)

         0

nk      1 row       1 col     (numeric)

         0

*LIT1004      1 row       1 col     (numeric)

         0

 statement : ASSIGN at line 131 column 1
131!                         /*initialize marshallian elasticity */
132  fic2=j(nk,nk,0);
ERROR: (execution) Invalid operand to operation.

 operation : J at line 132 column 7
 operands  : nk, nk, *LIT1005

nk      1 row       1 col     (numeric)

         0

nk      1 row       1 col     (numeric)

         0

*LIT1005      1 row       1 col     (numeric)

         0

 statement : ASSIGN at line 132 column 1
132!                    /*Initialize  Hicksian elasticity*/
133  fi2=j(nk,1,0)  /*Income elasticity vector*/
134  /*plotting elasticities*/
135  /*initialize index vector  */
136
137  x = j(nk*nk,1,0);
     -
     22
     76
ERROR 22-322: Syntax error, expecting one of the following: #, ##, &, (|, *, **, +, -, /, //, :,
              <, <=, <>, =, >, ><, >=, @, [, ^=, |, ||.

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

138    y = j(nk*nk,1,0);
ERROR: (execution) Invalid operand to operation.

 operation : J at line 138 column 8
 operands  : _TEM1001, *LIT1008, *LIT1009

_TEM1001      1 row       1 col     (numeric)

         0

*LIT1008      1 row       1 col     (numeric)

         1

*LIT1009      1 row       1 col     (numeric)

         0

 statement : ASSIGN at line 138 column 3
139
140    /* initialize vector to store elasticity matrices */
141    Helast = j(nk*nk,1,0);
ERROR: (execution) Invalid operand to operation.

 operation : J at line 141 column 13
 operands  : _TEM1001, *LIT1010, *LIT1011

_TEM1001      1 row       1 col     (numeric)

         0

*LIT1010      1 row       1 col     (numeric)

         1

*LIT1011      1 row       1 col     (numeric)

         0

 statement : ASSIGN at line 141 column 3
142    Melast = j(nk*nk,1,0);
ERROR: (execution) Invalid operand to operation.

 operation : J at line 142 column 13
 operands  : _TEM1001, *LIT1012, *LIT1013

_TEM1001      1 row       1 col     (numeric)

         0

*LIT1012      1 row       1 col     (numeric)

         1

*LIT1013      1 row       1 col     (numeric)

         0

 statement : ASSIGN at line 142 column 3
143
144    i=1;
145    do i=1 to nk;
146       fi2[i,1] = 1 + b[i,]/w[i,];
147       j=1;
148       do j=1 to nk;
149          ff2[i,j] = mi[i,j] + (gij[i,j] - b[i,]#(w[j,]-b[j,]#(lx-p)))/w[i,];
150          fic2[i,j] = ff2[i,j] + w[j,]#fi2[i,];
151          x[(i-1)*nk+j,1] = i ;
152    y[(i-1)*nk+j,1] = j ;
153    Melast[(i-1)*nk+j,1] = ff2[i,j] ;
154    Helast[(i-1)*nk+j,1] = fic2[i,j] ;
155       end;
156    end;
157  run;
NOTE: Module MAIN is undefined in IML; cannot be RUN.
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
      real time           2:22.51
      cpu time            3.54 seconds



158  PROC IML;
NOTE: IML Ready
159  use bau.consumo5;
160  read all var { B1 B2 B3 B4 B5 B6 B7 B8 B9 B11 B12 B13 B14 B15 B16
161  C1 C2 C3 C4 C5 C6 C7 C8 C9 C11 C12 C13 C14 C15 C16
162
163  U1 U2 U3 U4 U5 U6 U7 U8 U9 U11 U12 U13 U14 U15 U16
164  H1 H2 H3 H4 H5 H6 H7 H8 H9 H11 H12 H13 H14 H15 H16
165
166  P1 P2 P3 P4 P5 P6 P7 P8 P9 P11 P12 P13 P14 P15 P16
167  D1 D2 D3 D4 D5 D6 D7 D8 D9 D11 D12 D13 D14 D15 D16
168  F1 F2 F3 F4 F5 F6 F7 F8 F9 F11 F12 F13 F14 F15 F16
169  S11 S12 S13 S14 S15 S16 S17 S18 S19 S111 S112 S113 S114 S115 S116
170  S31 S32 S33 S34 S35 S36 S37 S38 S39 S311 S312 S313 S314 S315 S316
171  S51 S52 S53 S54 S55 S56 S57 S58 S59 S511 S512 S513 S514 S515 S516
172  S21 S22 S23 S24 S25 S26 S27 S28 S29 S211 S212 S213 S214 S215 S216
173  S61 S62 S63 S64 S65 S66 S67 S68 S69 S611 S612 S613 S614 S615 S616
174  S41 S42 S43 S44 S45 S46 S47 S48 S49 S411 S412 S413 S414 S415 S416
175  O1 O2 O3 O4 O5 O6 O7 O8 O9 O11 O12 O13 O14 O15 O16};
176  close bau.consumo5;
177
178  /*READ MEANS*/
179
180  use meanw;
181  READ ALL VAR{ witabread_less WITACHEESE_LESS  WITADAIRY_UHTLESS WITAHOVEN_LESS WITA_PASTALESS
181!  WITADAIRY_LESS WITAFRESHP_LESS WITABREAD_SUB WSUB_ITACHEESE  WSUB_ITAHOVEN WITADAIRY_SUB
181! WSUB_ITAPASTA WSUB_ITAFRESHP WOTHERPLUS LREXP };
182  close meanw;
183  run;
NOTE: Module MAIN is undefined in IML; cannot be RUN.
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
      real time           1:39.34
      cpu time            1.95 seconds


184  PROC IML;
NOTE: IML Ready
185  use bau.consumo5;
186  read all var { B1 B2 B3 B4 B5 B6 B7 B8 B9 B11 B12 B13 B14 B15 B16
187  C1 C2 C3 C4 C5 C6 C7 C8 C9 C11 C12 C13 C14 C15 C16
188
189  U1 U2 U3 U4 U5 U6 U7 U8 U9 U11 U12 U13 U14 U15 U16
190  H1 H2 H3 H4 H5 H6 H7 H8 H9 H11 H12 H13 H14 H15 H16
191
192  P1 P2 P3 P4 P5 P6 P7 P8 P9 P11 P12 P13 P14 P15 P16
193  D1 D2 D3 D4 D5 D6 D7 D8 D9 D11 D12 D13 D14 D15 D16
194  F1 F2 F3 F4 F5 F6 F7 F8 F9 F11 F12 F13 F14 F15 F16
195  S11 S12 S13 S14 S15 S16 S17 S18 S19 S111 S112 S113 S114 S115 S116
196  S31 S32 S33 S34 S35 S36 S37 S38 S39 S311 S312 S313 S314 S315 S316
197  S51 S52 S53 S54 S55 S56 S57 S58 S59 S511 S512 S513 S514 S515 S516
198  S21 S22 S23 S24 S25 S26 S27 S28 S29 S211 S212 S213 S214 S215 S216
199  S61 S62 S63 S64 S65 S66 S67 S68 S69 S611 S612 S613 S614 S615 S616
200  S41 S42 S43 S44 S45 S46 S47 S48 S49 S411 S412 S413 S414 S415 S416
201  O1 O2 O3 O4 O5 O6 O7 O8 O9 O11 O12 O13 O14 O15 O16};
202  close bau.consumo5;
203
204  /*READ MEANS*/
205
206  use meanw;
207  READ ALL VAR{ witabread_less WITACHEESE_LESS  WITADAIRY_UHTLESS WITAHOVEN_LESS WITA_PASTALESS
207!  WITADAIRY_LESS WITAFRESHP_LESS WITABREAD_SUB WSUB_ITACHEESE  WSUB_ITAHOVEN WITADAIRY_SUB
207! WSUB_ITAPASTA WSUB_ITAFRESHP WOTHERPLUS LREXP };
208  close meanw;
209  quit;
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds


210  /*BUDGET SHARE VECTOR*/
211  W=witabread_less // WITACHEESE_LESS // WITADAIRY_UHTLESS //WITAHOVEN_LESS//WITA_PASTALESS
     -
     180
211! //WITADAIRY_LESS //WITAFRESHP_LESS //WITABREAD_SUB //WSUB_ITACHEESE //WSUB_ITAHOVEN//
211! //WITADAIRY_SUB//WSUB_ITAPASTA  //WSUB_ITAFRESHP// WOTHERPLUS;

ERROR 180-322: Statement is not valid or it is used out of proper order.

212  /*GAMMA  IJ MATRIX */
213  /* TOLTO  (16) PERCHE’ E’ SU REDDITO tolta costante e numero 10*/
214  gij=(B1||B2||B3||B4||B5||B6||B7||B8||B9||B11||B12||B13||B14||B15)//
     ---
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.
215
216  (C1||C2||C3||C4||C5||C6||C7||C8||C9||C11||C12||C13||C14||C15)//
217
218  (U1||U2||U3||U4||U5||U6||U7||U8||U9||U11||U12| |U13||U14| U15)//
219  (H1||H2||H3||H4||H5||H6||H7||H8| |H9||H11| |H12||H13||H14||H15|)//
220
221  (P1||P2||P3||P4||P5||P6||P7||P8||P9||P11||P12||P13||P14||P15)//
222  (D1||D2||D3||D4||D5||D6||D7||D8||D9||D11||D12||D13||D14||D15)//
223  (F1||F2||F3||F4||F5||F6||F7||F8||F9||F11||F12||F13||F14||F15)//
224  (S11||S12||S13||S14||S15||S16||S17||S18||S19||S111||S112||S113| |S114||S115)//
225  (S30||S31||S32||S33||S34||S35||S36||S37||S38||S39||S310||S311||S312||S313| |S314||S315)//
226  (S51||S52||S53||S54||S55||S56||S57||S58||S59||S511||S512||S513| |S514||S515)//
227  (S21||S22||S23||S24||S25||S26||S27||S28||S29||S210||S211||S212||S213| |S214||S215)//
228  (S61||S62||S63||S64||S65||S66||S67||S68||S69||S611||S612||S613| |S614||S615)//
229  (S41||S42|S43||S44||S45||S46||S47||S48||S49||S410||S411||S412||S413||S414| |S415)//
230  (O1||O2||O3||O4||O5||O6||O7||O8||O9||O11| |O12||O13||O14||O15);

231  /* SUBITADAIRYUHT PARAMETERS*/
232  /* Bisognerebbe mettere una equazione per W SUBITADAIRYUHT
233  =0- B16-C16 U16-H16-P16-D16-F16-S116-S316-S516-S216-S616-   S416-O16;*/
234
235  /*CALCULATE  EACH ELEMENT OF THE ELASTICITY MATRIX*/
236  nk=ncol(gi);
     --
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

237  mi=-1#I(nk);
     --
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

238  ff2=j(nk,nk,0);
     ---
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

239  fic2=j(nk,nk,0);
     ----
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

240  fi2=j(nk,1,0)  /*Income elasticity vector*/
     ---
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.
241  /*plotting elasticities*/
242  /*initialize index vector  */
243
244  x = j(nk*nk,1,0);

245    y = j(nk*nk,1,0);
       -
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

246
247    /* initialize vector to store elasticity matrices */
248    Helast = j(nk*nk,1,0);
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

249    Melast = j(nk*nk,1,0);
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

250
251    i=1;
       -
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

252    do i=1 to nk;
       --
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

253       fi2[i,1] = 1 + b[i,]/w[i,];
          ---
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

254       j=1;
          -
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

255       do j=1 to nk;
          --
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

256          ff2[i,j] = mi[i,j] + (gij[i,j] - b[i,]#(w[j,]-b[j,]#(lx-p)))/w[i,];
             ---
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

257          fic2[i,j] = ff2[i,j] + w[j,]#fi2[i,];
             ----
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

258          x[(i-1)*nk+j,1] = i ;
             -
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

259    y[(i-1)*nk+j,1] = j ;
       -
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

260    Melast[(i-1)*nk+j,1] = ff2[i,j] ;
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

261    Helast[(i-1)*nk+j,1] = fic2[i,j] ;
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

262       end;
          ---
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

263    end;
       ---
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

264  W=witabread_less // WITACHEESE_LESS // WITADAIRY_UHTLESS //WITAHOVEN_LESS//WITA_PASTALESS
     -
     180
264! //WITADAIRY_LESS //WITAFRESHP_LESS //WITABREAD_SUB //WSUB_ITACHEESE //WSUB_ITAHOVEN//
264! //WITADAIRY_SUB//WSUB_ITAPASTA  //WSUB_ITAFRESHP// WOTHERPLUS;

ERROR 180-322: Statement is not valid or it is used out of proper order.

265  /*GAMMA  IJ MATRIX */
266  /* TOLTO  (16) PERCHE’ E’ SU REDDITO tolta costante e numero 10*/
267  gij=(B1||B2||B3||B4||B5||B6||B7||B8||B9||B11||B12||B13||B14||B15)//
     ---
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.
268
269  (C1||C2||C3||C4||C5||C6||C7||C8||C9||C11||C12||C13||C14||C15)//
270
271  (U1||U2||U3||U4||U5||U6||U7||U8||U9||U11||U12| |U13||U14| U15)//
272  (H1||H2||H3||H4||H5||H6||H7||H8| |H9||H11| |H12||H13||H14||H15|)//
273
274  (P1||P2||P3||P4||P5||P6||P7||P8||P9||P11||P12||P13||P14||P15)//
275  (D1||D2||D3||D4||D5||D6||D7||D8||D9||D11||D12||D13||D14||D15)//
276  (F1||F2||F3||F4||F5||F6||F7||F8||F9||F11||F12||F13||F14||F15)//
277  (S11||S12||S13||S14||S15||S16||S17||S18||S19||S111||S112||S113| |S114||S115)//
278  (S30||S31||S32||S33||S34||S35||S36||S37||S38||S39||S310||S311||S312||S313| |S314||S315)//
279  (S51||S52||S53||S54||S55||S56||S57||S58||S59||S511||S512||S513| |S514||S515)//
280  (S21||S22||S23||S24||S25||S26||S27||S28||S29||S210||S211||S212||S213| |S214||S215)//
281  (S61||S62||S63||S64||S65||S66||S67||S68||S69||S611||S612||S613| |S614||S615)//
282  (S41||S42|S43||S44||S45||S46||S47||S48||S49||S410||S411||S412||S413||S414| |S415)//
283  (O1||O2||O3||O4||O5||O6||O7||O8||O9||O11| |O12||O13||O14||O15);

284  /* SUBITADAIRYUHT PARAMETERS*/
285  /* Bisognerebbe mettere una equazione per W SUBITADAIRYUHT
286  =0- B16-C16 U16-H16-P16-D16-F16-S116-S316-S516-S216-S616-   S416-O16;*/
287
288  /*CALCULATE  EACH ELEMENT OF THE ELASTICITY MATRIX*/
289  nk=ncol(gi);
     --
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

290  mi=-1#I(nk);
     --
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

291  ff2=j(nk,nk,0);
     ---
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

292  fic2=j(nk,nk,0);
     ----
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

293  fi2=j(nk,1,0)  /*Income elasticity vector*/
     ---
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.
294  /*plotting elasticities*/
295  /*initialize index vector  */
296
297  x = j(nk*nk,1,0);

298    y = j(nk*nk,1,0);
       -
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

299
300    /* initialize vector to store elasticity matrices */
301    Helast = j(nk*nk,1,0);
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

302    Melast = j(nk*nk,1,0);
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

303
304    i=1;
       -
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

305    do i=1 to nk;
       --
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

306       fi2[i,1] = 1 + b[i,]/w[i,];
          ---
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

307       j=1;
          -
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

308       do j=1 to nk;
          --
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

309          ff2[i,j] = mi[i,j] + (gij[i,j] - b[i,]#(w[j,]-b[j,]#(lx-p)))/w[i,];
             ---
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

310          fic2[i,j] = ff2[i,j] + w[j,]#fi2[i,];
             ----
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

311          x[(i-1)*nk+j,1] = i ;
             -
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

312    y[(i-1)*nk+j,1] = j ;
       -
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

313    Melast[(i-1)*nk+j,1] = ff2[i,j] ;
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

314    Helast[(i-1)*nk+j,1] = fic2[i,j] ;
       ------
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

315       end;
          ---
          180

ERROR 180-322: Statement is not valid or it is used out of proper order.

316    end;
       ---
       180

ERROR 180-322: Statement is not valid or it is used out of proper order.

317  /*BUDGET SHARE VECTOR*/
318  W = witabread_less // WITACHEESE_LESS // WITADAIRY_UHTLESS //WITAHOVEN_LESS//WITA_PASTALESS
     -
     180
318! //WITADAIRY_LESS //WITAFRESHP_LESS //WITABREAD_SUB //WSUB_ITACHEESE //WSUB_ITAHOVEN//
318! //WITADAIRY_SUB//WSUB_ITAPASTA  //WSUB_ITAFRESHP// WOTHERPLUS;

ERROR 180-322: Statement is not valid or it is used out of proper order.

319  W = witabread_less // WITACHEESE_LESS // WITADAIRY_UHTLESS ;
     -
     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

Solution
‎06-30-2017 03:48 PM
SAS Super FREQ
Posts: 3,754

Re: Elasticities in Almost Idela demand system

You have two vertical concatenation operators in a row. Delete the trailing operator after WSUB_ITAHOVEN:

WSUB_ITAHOVEN//
//WITADAIRY_SUB

 

And to anticipate your next question, you also have an error in the horizontal concatenation:

U12| |U13||U14| U15

should be

U12||U13||U14||U15

 

You have dozens of similar errors, so please fix them all.

 

If I may make a suggestion, you might want to read multiple variables into a single matrix. It will make the code much shorter and simpler:

 

read all var ("B1":"B15") into B;
read all var ("C1":"C15") into C;
read all var ("U1":"U15") into U;
...
read all var {S11 S12 S13 S14 S15 S16 S17 S18 S19 S111 S112 S113 S114 S115} into S;
...

gij= B // C // U // ... // O;

 

If you are not familiar with the index creation operator (Smiley Happy, see the article "How to create column names for matrices."

New Contributor
Posts: 4

Re: Elasticities in Almost Idela demand system

OK. I'll try.

Thank you for your help.

MB

Frequent Contributor
Posts: 147

Re: Elasticities in Almost Idela demand system

In addtion to Rick's comments, I think you should remove the QUIT statement at line 209. This is the cause of the the ERROR 180-322 that you mentioned.

New Contributor
Posts: 4

Re: Elasticities in Almost Idela demand system

Posted in reply to IanWakeling

Thank you.

Regards

MB

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 226 views
  • 1 like
  • 3 in conversation