I am running PROC QLIM and generating a dataset of the coefficients using the OUTEST command. The variable names in the output dataset are of the form y.x, where y is the dependent variable and x is the independent variable. When I try to reference any of the variables in the dataset using the name (y.x) I get an error because SAS is trying to read the "y" portion of the name as a format. Does anyone know how to get around this problem? Thank you very much for the help.
Are you sure that you are looking at the variable names that are created and not the variable labels? The labels will be of the form y.x , but the variable names should have _ in them such as y_x.
See the simple example below for what the output should look like. Are you getting something different?
data a;
keep y1 y2 x1 x2;
do i = 1 to 500;
x1 = rannor( 19283 );
x2 = rannor( 19283 );
u1 = rannor( 19283 );
u2 = rannor( 19283 );
y1l = 1 + 2 * x1 + 3 * x2 + u1;
y2l = 3 + 4 * x1 - 2 * x2 + u1*.2 + u2;
if ( y1l > 0 ) then y1 = 1;
else y1 = 0;
if ( y2l > 0 ) then y2 = 1;
else y2 = 0;
output;
end;
run;
/*-- Bivariate Probit --*/
proc qlim data=a method=qn outest=out1;
init y1.x1 2.8, y1.x2 2.1, _rho .1;
model y1 = x1 x2;
model y2 = x1 x2;
endogenous y1 y2 ~ discrete;
run;
proc contents data=out1;
run;
Yes, the variable names I am getting are the same when I run PROC CONTENTS. The issue is if I run PROC MEANS on out1 for y1.x1 I get the syntax error
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, /, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
How can I reference these variables?
If you specify y1.x1 in the VAR statement in PROC MEANS you will certainly, and correctly, get an error. You should use the variable name in the VAR statement (or any other statement in any procedure) not the variable label. So, this should work:
proc means data=out1; var y1_x1; run;
That is what I thought, but when I run the code you supplied I get the following error
ERROR: Variable Y1_X1 not found.
The variable name from PROC CONTENTS suggests the name is Y1.X1, not Y1_X1, which is why the variable cannot be found.
You need to change the global option VALIDVARNAME to V7 before you run QLIM then. It sounds like you currently have it set to ANY.
options validvarname=v7;
proc qlim ....
Thank you very much. That worked!
Is ANY the default? Also, what does it mean when I change validvarname to v7?
V7 should be default so it must have been changed at some point.
That is strange, because when I open SAS Enterprise and simply run the code you provided I get the error. Unless I changed the default settings somehow it seems that V7 is not the default for me.
In the options in Enterprise Guide, click Tools►Options►Data General. In the Naming Options section, set the Valid variable names option to Basic variable names (V7). If this is a change, you will need to disconnect from and reconnect to the server.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.