BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fetcs74
Fluorite | Level 6

Hello,

 

I'm building XML files using EGuide and I've being using Proc Lua to pass the values to the XML, via Lua local variables. Now, I have more than 200 variables, so they cannot be defined as local, due to limitations to LUA itself. I tried a different approach that is defining only one local variable and then defining the other as attributes of this one. Something like this:

 

proc lua;
submit;
  local dsid = sas.open("sashelp.fish") -- open for input            
  local vars = {}
  local count=0
-- Iterate over the rows of the data set while sas.next(dsid) do count = count+1 local Species local fish = {} --Working Method
Species = sas.get_value(dsid, "species") --Not working method fish.species = sas.get_value(dsid, "species")
sas.submit [[ %Put Non-working: Species = @fish.species@; %Put Working: Species = @Species@; ]] end sas.close(dsid) endsubmit; run;

 

Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
fetcs74
Fluorite | Level 6

After some tests, I was able to find a solution. Instead of declaring each variable as local, I passed them as parameter when calling sas.submit:

 

proc lua;
submit;
  local dsid = sas.open("sashelp.fish") -- open for input            
  local vars = {}
  local count=0
  -- Iterate over the rows of the data set   
  while sas.next(dsid) do
	count = count+1

	sas.submit(
		[[
		%Put New working: Species =  @species2@;
		]],{species2=sas.get_value(dsid, "species")})


   end
   sas.close(dsid)
endsubmit;
run;

Note that LUA is case sensitive!

 

I hope that this can help someone.

 

Kind regards.

View solution in original post

2 REPLIES 2
fetcs74
Fluorite | Level 6

After some tests, I was able to find a solution. Instead of declaring each variable as local, I passed them as parameter when calling sas.submit:

 

proc lua;
submit;
  local dsid = sas.open("sashelp.fish") -- open for input            
  local vars = {}
  local count=0
  -- Iterate over the rows of the data set   
  while sas.next(dsid) do
	count = count+1

	sas.submit(
		[[
		%Put New working: Species =  @species2@;
		]],{species2=sas.get_value(dsid, "species")})


   end
   sas.close(dsid)
endsubmit;
run;

Note that LUA is case sensitive!

 

I hope that this can help someone.

 

Kind regards.

ChrisHemedinger
Community Manager

Glad you got it working! I had reached out to Paul Tomas, the SAS developer who works on PROC LUA -- but he was out these past few days, I think.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

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 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
  • 2 replies
  • 1530 views
  • 0 likes
  • 2 in conversation