Contents: | Purpose / History / Requirements / Usage / Details / Limitations |
%inc "<location of your file containing the TSCSDATA macro>";
Following this statement, you may call the %TSCSDATA macro. See the Results tab for an example.
The following arguments can be specified in the %TSCSDATA macro call. All are required except for IN=.
The %TSCSDATA macro requires a binary variable in the panel data set which identifies those observations to be included for the analysis. Use the keep= argument to specify this variable. Typically, the value for this variable is 1 initially for all observations.
The macro then changes the keep= variable value to 0 for those observations with missing values for any of the model variables and for those observations which violate the requirements (1) and (2) above. When the macro is invoked, it displays a note in the log indicating if an observation is excluded from the analysis.
Try invoking the macro an additional time if the preceding invocation results in exclusion of any observation. Once the macro has run without excluding additional observations, try running PROC TSCSREG using the WHERE clause.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
data tscs; drop _temp ; do state=1 to 50; do date=1 to 40; x1=normal(1); x2=normal(1); x3=normal(1); x4=normal(1); y=10*(1+x1+x2+x3+x4)+state+date+normal(1); _temp=(state<10)*(date>1); if _temp then x2=.; _temp=(state<50)*(date>30); if _temp then x3=.; output; end; end; run; * Add variable to indicate which observations are included in the subset for PROC TSCSREG. Initialize with the value 1.0. *; data tscs; set tscs; _keep=1.0; run; title "DATA TSCS generate an error causing TSCSREG to fail"; proc tscsreg data=tscs; where _keep=1; id state date; model y=x1-x4/rantwo fixtwo; run; * First invocation of %TSCSDATA macro results in exclusion of additional observations, as noted in the SAS log. %TSCSDATA should be run again until no observations are excluded. *; %inc "<location of your file containing the TSCSDATA macro>"; %tscsdata(in=tscs, out=tscs, ts=date, cs=state, vars=y x1 x2 x3 x4, nreg=4, keep=_keep) * Now the second invocation of %TSCSDATA. It results in no additional observations being excluded. So we can try running PROC TSCSREG again, using the where clause to identify which observations are included/excluded. *; %tscsdata(in=tscs, out=tscs, ts=date, cs=state, vars=y x1 x2 x3 x4, nreg=4, keep=_keep) title "TSCSREG will now run"; proc tscsreg data=tscs; where _keep=1; id state date; model y=x1-x4/rantwo fixtwo; run;
proc tscsreg data=tscs; where _keep=1; id state date; model y=x1-x4/rantwo fixtwo; run; ERROR: Not enough observations with non-missing model variables for model statement in cross section state=1. %tscsdata(in=tscs, out=tscs, ts=date, cs=state, vars=y x1 x2 x3 x4, nreg=4, keep=_keep) Observations excluded due to missing model variable values: Obs=2 state=1 date=2 Obs=3 state=1 date=3 Obs=4 state=1 date=4 Obs=5 state=1 date=5 Obs=6 state=1 date=6 Obs=7 state=1 date=7 Obs=8 state=1 date=8 Obs=9 state=1 date=9 ... listing continues ... Obs=1959 state=49 date=39 Obs=1960 state=49 date=40 Number excluded due to missing values: 751 Observations excluded due to too few time points for the cross section: Obs=1 state=1 date=1 Obs=41 state=2 date=1 Obs=81 state=3 date=1 Obs=121 state=4 date=1 Obs=161 state=5 date=1 Obs=201 state=6 date=1 Obs=241 state=7 date=1 Obs=281 state=8 date=1 Obs=321 state=9 date=1 Number excluded due to too few time series values: 9 Observations excluded due to too few cross section values for a time point: Obs=1550 state=50 date=31 Obs=1600 state=50 date=32 Obs=1650 state=50 date=33 Obs=1700 state=50 date=34 Obs=1750 state=50 date=35 Obs=1800 state=50 date=36 Obs=1850 state=50 date=37 Obs=1900 state=50 date=38 Obs=1950 state=50 date=39 Obs=2000 state=50 date=40 Number excluded due to too few cross section values: 10 %tscsdata(in=tscs, out=tscs, ts=date, cs=state, vars=y x1 x2 x3 x4, nreg=4, keep=_keep) Observations excluded due to missing model variable values: Number excluded due to missing values: 0 Observations excluded due to too few time points for the cross section: Number excluded due to too few time series values: 0 Observations excluded due to too few cross section values for a time point: Number excluded due to too few cross section values: 0
Right-click on the link below and select Save to save
the %TSCSDATA macro definition
to a file. It is recommended that you name the file
tscsdata.sas
.
Download and save tscsdata.sas
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> TSCSREG |
Date Modified: | 2016-06-01 15:21:14 |
Date Created: | 2005-01-13 15:02:53 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/ETS | All | n/a | n/a |