Help using Base SAS procedures

PROC LUA - Resolving variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

PROC LUA - Resolving variables

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! 


Accepted Solutions
Solution
‎05-25-2016 04:24 AM
Occasional Contributor
Posts: 10

Re: PROC LUA - Resolving variables

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


All Replies
Solution
‎05-25-2016 04:24 AM
Occasional Contributor
Posts: 10

Re: PROC LUA - Resolving variables

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.

Community Manager
Posts: 2,768

Re: PROC LUA - Resolving variables

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 485 views
  • 0 likes
  • 2 in conversation