Obsidian | Level 7

Elasticities matrices ERROR

Hello

I am a beginner in SAS and i need to make elasticities matrices on it. I did my best to use the PDF code provided by SAS for a translog function but i have an ERROR that i am trying to solv for more than a weak and still nothing.

Please if you can hel i need to get the result ASAP.

Thanks a lot

376 proc iml;
378 use est;
379 read all var {gcc gcg gcf gch gce gcs};
380 read all var {ggg ggf ggh gge ggs};
381 read all var {ghh ghf ghe ghs};
382 read all var {gee gef ges};
383 read all var {gss gsf};
384 close est;
385
386 /*Calculate S parameter based on homogeneity constraint*/
387 gfs=0-gcs-ggs-ghs-ges-gss;
388
389 /*Read in mean cost shares and construct vector*/
390 use meanshares;
391 read all var {sc sg sf sh se ss};
392 close meanshares;
393
394 w = sc//sg//sf//sh//se//ss;
395
396 print w;
397
398 /*Construct matrix of parameter estimates*/
399 gij = (gcc||ggc||gcf||gch||gce||gsc)//
400 (ggc||ggg||ggf||ggh||gge||ggs)//
401 (gcf||ggf||gff||gfh||gfe||gfs)//
402 (gch||ggh||gfh||ghh||ghe||ghs)//
403 (gce||gge||gfe||ghe||gee||ges)//
404 (gsc||ggs||gfs||ghs||ges||gss) ;
ERROR: (execution) Matrices do not conform to the operation.

operation : // at line 399 column 39
operands : _TEM1005, _TEM1010

_TEM1005 1 row 4 cols (numeric)

-0.179326 0.0149951 0.1827359 -0.001691

_TEM1010 1 row 5 cols (numeric)

-0.004915 -0.008446 0.0382183 -0.004144 -0.003238

statement : ASSIGN at line 399 column 3
405
406 print gij;
ERROR: Matrix gij has not been set to a value.

statement : PRINT at line 406 column 4
407
408 nk=ncol(gij);
409 mi = -1#I(nk);
ERROR: (execution) Invalid operand to operation.

operation : I at line 409 column 13
operands : nk

nk 1 row 1 col (numeric)

0

statement : ASSIGN at line 409 column 4
409 ! /*Initialize negative identity matrix*/
410 eos = j(nk,nk,0);
ERROR: (execution) Invalid operand to operation.

operation : J at line 410 column 11
operands : nk, nk, *LIT1009

nk 1 row 1 col (numeric)

0

nk 1 row 1 col (numeric)

0

*LIT1009 1 row 1 col (numeric)

0

statement : ASSIGN at line 410 column 4
410 ! /*Initialize Marshallian EOS Matrix*/
411 mos = j(nk,nk,0);
ERROR: (execution) Invalid operand to operation.

operation : J at line 411 column 11
operands : nk, nk, *LIT1010

nk 1 row 1 col (numeric)

0

nk 1 row 1 col (numeric)

0

*LIT1010 1 row 1 col (numeric)

0

statement : ASSIGN at line 411 column 4
411 ! /*Initialize Morishima EOS Matrix*/
412 ep = j(nk,nk,0);
ERROR: (execution) Invalid operand to operation.

operation : J at line 412 column 11
operands : nk, nk, *LIT1011

nk 1 row 1 col (numeric)

0

nk 1 row 1 col (numeric)

0

*LIT1011 1 row 1 col (numeric)

0

statement : ASSIGN at line 412 column 4
412 ! /*Initialize Price EOD Matrix*/
413
414 /*Calculate Marshallian EOS and Price EOD Matrices*/
415 i=1;
416 do i=1 to nk;
417 j=1;
418 do j=1 to nk;
419 eos[i,j] = (gij[i,j]+w[i]#w[j]+mi[i,j]#w[i])/(w[i]#w[j]);
420 ep[i,j] = w[j]#eos[i,j];
421 end;
422 end;
423
424 /*Calculate Morishima EOS Matrix*/
425 i=1;
426 do i=1 to nk;
427 j=1;
428 do j=1 to nk;
429 mos[i,j] = ep[i,j]-ep[j,j];
430 end;
431 end;
432
433 /*Print Elasticity Matrices*/
434 factors = {"Coal" "Gas" "Fuel" "Hydraulic" "Wind" "Solar"};
435 print
436 ep[label="Price Elasticities of Demand" rowname=factors colname=factors
437 format=d7.3],
438 eos[label="Hicks-Allen Elasticities of Substitution" rowname=factors colname=factors
439 format=d7.3],
440 mos[label="Morishima Elasticities of Substitution" rowname=factors colname=factors
441 format=d7.3];
ERROR: Matrix ep has not been set to a value.

statement : PRINT at line 435 column 4
442
443
444
445
446 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
458

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

Re: Elasticities matrices ERROR

Haven't looked through all the error messages, but at line 399 you do a lot of concatenation of matrices. However, there is a mismatch between the dimensions as one of the vectors has 4 columns and another has 5.

Use

``show names;``

to check the attributes of all of the matrices in your current IML session and work from there.

3 REPLIES 3
Super User

Re: Elasticities matrices ERROR

Haven't looked through all the error messages, but at line 399 you do a lot of concatenation of matrices. However, there is a mismatch between the dimensions as one of the vectors has 4 columns and another has 5.

Use

``show names;``

to check the attributes of all of the matrices in your current IML session and work from there.

Obsidian | Level 7

Re: Elasticities matrices ERROR

Thank you very much for your prompt reply and for the help.

It was as you said a problem of dimension and i replaced this part :

"read all var {gcc gcg gcf gch gce gcs};
380 read all var {ggg ggf ggh gge ggs};
381 read all var {ghh ghf ghe ghs};
382 read all var {gee gef ges};
383 read all var {gss gsf};"

I didn't include all the vectors so to avoid having one with 4 and another with 5 i did this :

read all var {gcc gcg gcf gch gce gcs ggc ggg ggf ggh gge ggs ghc ghg ghf ghh ghe ghs gec geg gef geh gee ges gsc gsg gsf gsh gse gss};

Super User