BookmarkSubscribeRSS Feed
jjschild
Calcite | Level 5

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. 

 

9 REPLIES 9
SAS_Rob
SAS Employee

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;

 

jjschild
Calcite | Level 5

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? 

StatDave
SAS Super FREQ

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;
jjschild
Calcite | Level 5

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. 

SAS_Rob
SAS Employee

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 ....

jjschild
Calcite | Level 5

Thank you very much. That worked! 

 

Is ANY the default? Also, what does it mean when I change validvarname to v7?

 

SAS_Rob
SAS Employee

V7 should be default so it must have been changed at some point.  

jjschild
Calcite | Level 5

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. 

 

StatDave
SAS Super FREQ

In the options in Enterprise Guide, click ToolsOptionsData 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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 9 replies
  • 666 views
  • 1 like
  • 3 in conversation