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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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