BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
EyalGonen
Lapis Lazuli | Level 10

Hi experts,

 

Question is for SAS Viya 2022.9

 

In PROC LUA one could invoke SAS functions directly for example:

 

proc lua;
submit;
local dsid = sas.open("sashelp.class")
for row in dsid:rows() do
print(row.age, row.height)
end
dsid:close()
endsubmit;
run;

 

I am struggling to do the same with PROC PYTHON. For example to invoke the "sas.open" function I found only this way which is kind of cumbersome compared to PROC LUA:

 

dsid = SAS.sasfnc("open","sashelp.class")

 

And I could not find the equivalent of "dsid:rows()" in PROC PYTHON.

Am I missing something?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

For actions specific to working with a data table, I think you would use SAS.sd2df to convert the data set into a pandas data frame, and then use the Python friendly data frame methods.

 

Otherwise, yes -- I think the way to invoke SAS functions generically from Python is the SAS.sasfnc method -- there isn't a Python-specific wrapper for each SAS function (or even the most commonly used ones).

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

1 REPLY 1
ChrisHemedinger
Community Manager

For actions specific to working with a data table, I think you would use SAS.sd2df to convert the data set into a pandas data frame, and then use the Python friendly data frame methods.

 

Otherwise, yes -- I think the way to invoke SAS functions generically from Python is the SAS.sasfnc method -- there isn't a Python-specific wrapper for each SAS function (or even the most commonly used ones).

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 754 views
  • 0 likes
  • 2 in conversation