BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
Hi,
I am getting this error, can any one help me.
thank you

GETVARN referenced by the %SYSFUNC or %QSYSFUNC macro function
is out of range.

my code:
%MACRO SaveItemOrder;
%let ordervar=3;
DATA _NULL_;
/* Datasets to draw values from*/
%LET dataQmatrix=%SYSFUNC(OPEN(work.Qmatrix,i));
%DO i=1 %TO 7;
/* Assign new macro variables as global*/
%GLOBAL itemorder&i;
/* Gets entire row of data*/
%LET row=%SYSFUNC(FETCHOBS(&dataQmatrix,&i));
/* Grabs specific value for threshold from that row*/
%LET item&i.=%SYSFUNC(GETVARN(&dataQmatrix.,
%SYSFUNC(VARNUM(&dataQmatrix.,&ordervar.))));
/* Transferring value to global macro, and checking via log;*/
%LET itemorder&i. = &&item&i.;
%PUT itemorder&i. &&itemorder&i.;
%END;
/* Close dataset used in program;*/
%LET dataQmatrix=%SYSFUNC(CLOSE(&dataQmatrix.));
RUN;
%MEND;
%SaveItemOrder;
3 REPLIES 3
ariari
Calcite | Level 5
Hi R.A.G.

the problem is in second parametr of the GETVARN function. It should be the number of the variable in the Data Set.
from now you have 2 options:
1 . %LET item&i.=%SYSFUNC(GETVARN(&dataQmatrix.,&ordervar.));

2. if you want use VARNUM function you need change second paramets. Instead of &ordervar use var name.

Irena
R_A_G_
Calcite | Level 5
Hi Irena ,

Thanks that helped. I have another question. when using this function:
%LET item&i.=%SYSFUNC(GETVARN(&dataQmatrix.,&ordervar.));

Are we telling SAS to look at each row of the data or each column of the data?

Thanks again
R.G.
Cynthia_sas
SAS Super FREQ
Hi:
GETVARN returns the value of a numeric VARIABLE:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148384.htm

However, you cannot debug GETVARN separate from the OPEN, FETCHOBS VARNUM and CLOSE functions. They are all documented in the Function and Call Routine doc:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245852.htm

cynthia

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2328 views
  • 0 likes
  • 3 in conversation