Help using Base SAS procedures

Proc panel - problems with reading the data statement

Reply
New Contributor msj
New Contributor
Posts: 4

Proc panel - problems with reading the data statement

Hi all

 

 

I am trying to do a fixed effect and random effect estimation for some panel data, and I thought proc panel would be the best procedure to use. However when I am using the procedure, the data statement does not turn blue, as it should and as it does when I am using the proc reg statement. This is shown below:

proc panel.PNG

When I am running this code I get the error:

ERROR 22-322: Expecting a name.
55 model y = x1 x2 /fixone;
ERROR: Variable NAME not found.
56 run;

 

To me it seems like it does not read the data statement, which is why it cannot find the variable and gives the error.

 

Why can't SAS read the statement and how can I use this fixed effect estimation with proc panel? Or is there an even easier way than this (I have a lot of observations).

 

 

Best regards

Marc

Super User
Posts: 19,815

Re: Proc panel - problems with reading the data statement

No, the syntax not highlighting correctly is annoying but has no effect on the code. 

 

Post your full log please, there's an error but I suspect it may be earlier on in your code.

 

 

New Contributor msj
New Contributor
Posts: 4

Re: Proc panel - problems with reading the data statement

Thanks for the quick reply.

 

The full log is here:

NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M4)
      Licensed to CAMPUS - KBH. UNI. WNDW - 64BIT, Site 70087676.
NOTE: This session is executing on the X64_10HOME  platform.



NOTE: Updated analytical products:

      SAS/STAT 14.2
      SAS/ETS 14.2
      SAS/OR 14.2
      SAS/IML 14.2
      SAS/QC 14.2

NOTE: Additional host information:

 X64_10HOME WIN 10.0.14393  Workstation

NOTE: SAS initialization used:
      real time           0.71 seconds
      cpu time            0.59 seconds

1    PROC IMPORT OUT= work.density DATAFILE= "C:\Users\bruger\OneDrive\KU\10. semester\Urban
1  ! Economics\Area\density"
2                DBMS=xlsx replace;
3         SHEET="dens";
4         GETNAMES=YES;
5    RUN;

NOTE: The import data set has 588 observations and 4 variables.
NOTE: WORK.DENSITY data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.04 seconds


6
7    libname out "C:\Users\bruger\OneDrive\KU\10. semester\Urban Economics\Area";
NOTE: Libref OUT was successfully assigned as follows:
      Engine:        V9
      Physical Name: C:\Users\bruger\OneDrive\KU\10. semester\Urban Economics\Area
8    data out.density;
9    set density;
10   run;

NOTE: There were 588 observations read from the data set WORK.DENSITY.
NOTE: The data set OUT.DENSITY has 588 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


11
12   PROC IMPORT OUT= work.house DATAFILE= "C:\Users\bruger\OneDrive\KU\10. semester\Urban
12 ! Economics\Area\density"
13               DBMS=xlsx replace;
14        SHEET="house";
15        GETNAMES=YES;
16   RUN;

NOTE: The import data set has 588 observations and 3 variables.
NOTE: WORK.HOUSE data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


17
18   libname out "C:\Users\bruger\OneDrive\KU\10. semester\Urban Economics\Area";
NOTE: Libref OUT was successfully assigned as follows:
      Engine:        V9
      Physical Name: C:\Users\bruger\OneDrive\KU\10. semester\Urban Economics\Area
19   data out.house;
20   set house;
21   run;

NOTE: There were 588 observations read from the data set WORK.HOUSE.
NOTE: The data set OUT.HOUSE has 588 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


22
23
24   proc reg data=density;
NOTE: Writing HTML Body file: sashtml.htm
25   model y = beko empdens;
26   run;

27

NOTE: PROCEDURE REG used (Total process time):
      real time           2.20 seconds
      cpu time            0.51 seconds


28   proc panel data=density;
29   id year;
            -
            22
ERROR 22-322: Expecting a name.
30   model y = empdens /fixone;
ERROR: Variable NAME not found.
31   run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PANEL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds

The log does not show an error before the proc panel code.

 

Regards

Marc

 

Super User
Posts: 19,815

Re: Proc panel - problems with reading the data statement

Try the following section of code. I think it's an error in your ID statement. Do you have duplicates where you shouldn't?

I was able to replicate the issue with duplicates in my ID variable. 

 

proc sort data=density;
by year;
run;

proc panel data=density;
model y = empdens / fixone;

id year;
run;

If that doesn't work, let me know what happens if you run the following:

 

data a;
   length state $ 2;
   input state $ year d t s y rd rt rs;
   label d = 'Per Capita Demand Deposits'
        t = 'Per Capita Time Deposits'
        s = 'Per Capita S & L Association Shares'
        y = 'Permanent Per Capita Personal Income'
        rd = 'Service Charge on Demand Deposits'
        rt = 'Interest on Time Deposits'
        rs = 'Interest on S & L Association Shares';
datalines;
CA   1949  6.2785  6.1924  4.4998  7.2056 -1.0700  0.1080  1.0664
CA   1950  6.4019  6.2106  4.6821  7.2889 -1.0106  0.1501  1.0767
CA   1951  6.5058  6.2729  4.8598  7.3827 -1.0024  0.4008  1.1291
CA   1952  6.4785  6.2729  5.0039  7.4000 -0.9970  0.4492  1.1227
CA   1953  6.4118  6.2538  5.1761  7.4200 -0.8916  0.4662  1.2110
CA   1954  6.4520  6.2971  5.3613  7.4478 -0.6951  0.4756  1.1924
CA   1955  6.4998  6.3081  5.5452  7.4838 -0.7012  0.4929  1.2387
CA   1956  6.5162  6.2897  5.7236  7.5380 -0.6292  0.5636  1.2638
CA   1957  6.4646  6.3733  5.8579  7.5822 -0.4620  0.9712  1.3686
CA   1958  6.5191  6.4552  6.0331  7.6178 -0.4050  0.9712  1.3818
CA   1959  6.5709  6.4661  6.2025  7.6797 -0.4095  0.9738  1.3980
DC   1949  6.7499  5.4806  5.8230  7.3796 -1.3432 -0.3916  1.0307
DC   1950  6.9207  5.5413  5.9454  7.4804 -1.3205 -0.4125  1.0567
DC   1951  7.0775  5.6131  6.1420  7.6094 -1.3243 -0.3901  1.1006
DC   1952  6.9810  5.5452  6.2166  7.5606 -1.3205 -0.3161  1.0902
DC   1953  6.9117  5.5530  6.2971  7.5262 -1.2483 -0.1244  1.1102
DC   1954  6.9508  5.7203  6.4394  7.5326 -1.1777  0.4055  1.1259
DC   1955  6.9726  5.7961  6.5820  7.5658 -1.1457  0.4081  1.1559
DC   1956  6.9679  5.7991  6.6670  7.5761 -1.1332  0.4688  1.1787
DC   1957  7.0211  5.9687  6.8002  7.6425 -1.0613  0.8024  1.2143
DC   1958  7.0867  6.0799  6.9197  7.6704 -1.0217  0.7419  1.2404
DC   1959  7.0630  6.0014  7.0291  7.6811 -0.8723  0.8510  1.3156
FL   1949  6.0113  4.8363  4.6347  6.9315 -1.0385 -0.0954  0.8390
FL   1950  6.0707  4.8283  4.7274  6.9147 -1.0729 -0.0440  0.8446
FL   1951  6.1506  4.8903  4.9345  6.9735 -1.0936  0.0020  0.8871
FL   1952  6.1527  4.8828  5.1180  6.9735 -1.1147  0.0507  0.9466
FL   1953  6.1399  4.9273  5.2983  7.0370 -1.0385  0.1115  0.9651
FL   1954  6.1420  4.9416  5.5094  7.0361 -0.9835  0.2374  1.0547
FL   1955  6.3008  5.0814  5.8111  7.1747 -0.9729  0.2919  1.0585
FL   1956  6.3404  5.1120  5.9480  7.1997 -0.9188  0.3961  1.1092
FL   1957  6.2748  5.3660  6.0355  7.2320 -0.8052  0.8838  1.2054
FL   1958  6.2785  5.4806  6.1026  7.2506 -0.6972  0.8973  1.2099
FL   1959  6.2577  5.4596  6.2344  7.2841 -0.6482  0.9119  1.2740
IL   1949  6.7370  5.8749  4.7536  7.2896 -1.9449 -0.1602  0.9179
IL   1950  6.7569  5.8348  4.8363  7.2917 -1.9241 -0.1661  0.8953
IL   1951  6.7878  5.8141  4.9698  7.3492 -1.9173 -0.0661  0.8957
IL   1952  6.8178  5.9402  5.1648  7.4073 -1.9379  0.0573  0.9431
IL   1953  6.8123  5.9814  5.3423  7.4448 -1.8971  0.0871  0.9944
IL   1954  6.8330  6.0259  5.5334  7.4816 -1.8079  0.1222  1.0109
IL   1955  6.8448  6.0259  5.6904  7.5038 -1.7603  0.1319  1.0217
IL   1956  6.8501  6.0568  5.8579  7.5575 -1.6983  0.3031  1.0757
IL   1957  6.8013  6.0913  5.9713  7.5909 -1.5945  0.4874  1.1490
IL   1958  6.8233  6.1399  6.0958  7.6014 -1.5418  0.5522  1.2244
IL   1959  6.7731  6.1633  6.1924  7.6183 -1.4653  0.7198  1.2519
NY   1949  7.2226  5.6021  4.2047  7.3079 -2.1893 -0.3754  0.7415
NY   1950  7.2478  5.5645  4.2627  7.3232 -2.1286 -0.3230  0.7333
NY   1951  7.2506  5.5334  4.4427  7.3563 -2.1286 -0.2294  0.7966
NY   1952  7.2591  5.6058  4.6250  7.4140 -2.1203  0.0488  0.8899
NY   1953  7.2406  5.6904  4.7707  7.4639 -2.0099  0.2159  0.9070
NY   1954  7.2549  5.7621  4.9053  7.4967 -1.9310  0.2971  0.9322
NY   1955  7.2661  5.7462  5.0039  7.5000 -1.9241  0.3407  0.9764
NY   1956  7.2556  5.8260  5.1240  7.5580 -1.7838  0.5619  1.0203
NY   1957  7.2745  5.9915  5.2417  7.6372 -1.6660  0.8024  1.0842
NY   1958  7.2814  6.1137  5.3279  7.6592 -1.6503  0.8587  1.1227
NY   1959  7.2563  6.1181  5.4072  7.6948 -1.5945  0.9247  1.1703
TX   1949  6.3509  4.2341  3.5835  6.9027 -1.9038 -0.1755  1.0134
TX   1950  6.4520  4.2627  3.7377  6.9584 -1.9173 -0.1791  1.0080
TX   1951  6.5206  4.3438  3.8918  7.0510 -1.9105 -0.2083  1.0364
TX   1952  6.5043  4.4308  4.0604  7.0699 -1.9173  0.0677  1.0578
TX   1953  6.5013  4.5951  4.2905  7.1131 -1.8326  0.1570  1.1256
TX   1954  6.5624  4.7622  4.5218  7.1585 -1.7037  0.2837  1.1291
TX   1955  6.5820  4.8442  4.7095  7.1967 -1.6555  0.3133  1.1220
TX   1956  6.5624  4.8828  4.8203  7.2138 -1.5702  0.4344  1.1210
TX   1957  6.5147  5.0689  4.9698  7.2556 -1.3863  0.7519  1.2490
TX   1958  6.5737  5.3033  5.1059  7.2841 -1.2801  0.8069  1.2276
TX   1959  6.5554  5.3519  5.2781  7.3265 -1.1940  0.8899  1.3005
WA   1949  6.0355  5.3033  4.4998  7.0440 -1.0272 -0.0651  0.7266
WA   1950  6.2166  5.3753  4.6913  7.1884 -1.0189 -0.0274  0.8016
WA   1951  6.2634  5.3936  4.8520  7.2675 -1.0079  0.0383  0.8616
WA   1952  6.2519  5.4381  4.9698  7.3005 -0.9650  0.2662  0.9373
WA   1953  6.2146  5.4596  5.1591  7.3337 -0.8819  0.2942  1.0466
WA   1954  6.2860  5.5094  5.3613  7.3790 -0.7319  0.2986  1.0526
WA   1955  6.3008  5.5835  5.5053  7.4079 -0.6368  0.5710  1.0671
WA   1956  6.2634  5.5910  5.5722  7.4122 -0.5327  0.5761  1.1023
WA   1957  6.2025  5.6595  5.6525  7.4448 -0.3842  0.8385  1.1793
WA   1958  6.2558  5.7333  5.7621  7.4697 -0.3341  0.8338  1.1957
WA   1959  6.2442  5.7557  5.8435  7.5005 -0.3147  0.9143  1.2548
;

proc sort data=a;
   by state year;
run;

proc panel data=a;
model t = y rd rt rs / fixone;
id  state year;
run;
New Contributor msj
New Contributor
Posts: 4

Re: Proc panel - problems with reading the data statement

Thank you so much! 

Your code is working perfectly. I guess the problem is I only used "year" in the id statement. When I am using year and another variable it is working.

 

Thanks for the help.

Super User
Posts: 19,815

Re: Proc panel - problems with reading the data statement

I would report this to SAS tech support, it should be more clear and the error is definitely not clear when it could identify that their is an issue with the ID statement. 

Super User
Super User
Posts: 7,050

Re: Proc panel - problems with reading the data statement

Not sure if SAS can tweak the error generator to give a better error message, but the documentation clearly shows that you need to give two variable names on the ID statement.

 

ID Statement

  • ID cross-section-id time-series-id;

The ID statement is used to specify variables in the input data set that identify the cross section and time period for each observation.

When an ID statement is used, the PANEL procedure verifies that the input data set is sorted by the cross section ID variable and by the time series ID variable within each cross section. The PANEL procedure also verifies that the time series ID values are the same for all cross sections.

To make sure the input data set is correctly sorted, use PROC SORT to sort the input data set with a BY statement with the variables listed exactly as they are listed in the ID statement, as shown in the following statements:

   proc sort data=a;
      by csid tsid;
   run;

   proc panel data=a;
      id csid tsid;
      ... etc. ...
   run;
Ask a Question
Discussion stats
  • 6 replies
  • 103 views
  • 1 like
  • 3 in conversation