yesterday
sastpw
SAS Employee
Member since
05-09-2017
- 203 Posts
- 39 Likes Given
- 28 Solutions
- 77 Likes Received
-
Latest posts by sastpw
Subject Views Posted 408 01-24-2025 02:47 PM 335 01-21-2025 02:00 PM 451 01-16-2025 01:43 PM 682 01-16-2025 12:27 PM 584 01-16-2025 10:32 AM 740 01-13-2025 04:05 PM 992 01-13-2025 03:54 PM 999 01-13-2025 03:50 PM 2265 12-03-2024 01:34 PM 2323 12-03-2024 10:14 AM -
Activity Feed for sastpw
- Liked Weekly Workbench Tip: Bonus function for python users for ajaypanjwani. 02-03-2025 10:16 AM
- Posted Re: Trouble running SAS in jupyter notebook on SAS Software for Learning Community. 01-24-2025 02:47 PM
- Posted Re: SASPy submit result of running .sas code on SAS Programming. 01-21-2025 02:00 PM
- Got a Like for Re: SASPy submit result of running .sas code. 01-19-2025 05:45 PM
- Posted Re: SASPy submit result of running .sas code on SAS Programming. 01-16-2025 01:43 PM
- Posted Re: SASPy submit result of running .sas code on SAS Programming. 01-16-2025 12:27 PM
- Posted Re: SASPY connection issue to ODA (OnDemand for Academics) on New SAS User. 01-16-2025 10:32 AM
- Got a Like for Re: SASPy submit result of running .sas code. 01-14-2025 04:07 AM
- Got a Like for Re: SASPy submit result of running .sas code. 01-13-2025 07:43 PM
- Posted Re: SASPY connection issue to ODA (OnDemand for Academics) on New SAS User. 01-13-2025 04:05 PM
- Posted Re: SASPy submit result of running .sas code on SAS Programming. 01-13-2025 03:54 PM
- Posted Re: SASPy submit result of running .sas code on SAS Programming. 01-13-2025 03:50 PM
- Posted Re: SASPy: sd2df_DISK() parameter dtype on Developers. 12-03-2024 01:34 PM
- Posted Re: SASPy: sd2df_DISK() parameter dtype on Developers. 12-03-2024 10:14 AM
- Got a Like for Re: SASPy: sd2df_DISK() parameter dtype. 12-03-2024 09:36 AM
- Posted Re: SASPy: sd2df_DISK() parameter dtype on Developers. 12-03-2024 09:29 AM
- Got a Like for Re: SAS 94M8 iom bridge with python on linux. 10-28-2024 05:14 AM
- Posted Re: SAS 94M8 iom bridge with python on linux on Administration and Deployment. 10-23-2024 04:21 PM
- Posted Re: SAS 94M8 iom bridge with python on linux on Administration and Deployment. 10-23-2024 04:16 PM
- Posted Re: Query Regarding SAS Kernel connection through https method in Jupyter notebook. on SAS Viya. 10-17-2024 04:48 PM
-
Posts I Liked
Subject Likes Author Latest Post 3 1 7 1 1 -
My Liked Posts
Subject Likes Posted 1 01-16-2025 12:27 PM 1 01-13-2025 03:54 PM 1 01-13-2025 03:50 PM 1 12-03-2024 09:29 AM 1 10-23-2024 04:21 PM -
My Library Contributions
Subject Likes Author Latest Post 1
01-24-2025
02:47 PM
SAS_kernel depends on SASPy, so when you install it, it will install SASPy if it's not already there; so that part should be ok.
The error implies that you haven't configured saspy to have any idea what SAS deployment it's supposed to be connecting to. The documentation for configuring SASPy is here: https://sassoftware.github.io/saspy/configuration.html
There are different access methods for connecting to different kinds of SAS deployments. w/in that configuration doc will be a section that helps you identify which access method to configure depending upon where your client is and where/what kind of SAS deployment you're trying to connect to.
... View more
01-21-2025
02:00 PM
No, I don't have check_warnings or check_notes. You can check for anything in the log you'd like; submit returns the log and something as simple as if re.search(r'\nERROR[ \d-]*:', log):
can be used to look for others. There's no magic thing I can check for, for any code ever submitted, that proves everything worked or didn't. SAS doesn't really have that concept. Saying it failed because there was a warning isn't really correct anyway. Just seeing an error doesn't mean it failed either; you can get an error in the log and things still succeeded. That logic is something you want to determine based upon what you're running and what you expect.
I get that trying to automate this for code you didn't write isn't straight forward. I suppose looking for errors or warnings and then telling someone to look at the code/log and see if there weas an issue or not is simple. But you can't simply prove it worked or not w/out knowing what's going on.
... View more
01-16-2025
01:43 PM
Not sure what that code is.
But, the example I showed was from one of the access methods that doesn't have the issue with user content showing up embedded prior to the actual SAS log line (I think it was IOM). The STDIO access method has to deal with that, and in it the check has to deal with that:
def _checkLogForError(self, log): lines = re.split(r'[\n]\s*', log) for line in lines: if re.search(r'^ERROR[ \d-]*:', line[self._sb.logoffset:]): return (True) return (False)
Do you have some code where this isn't doing what you need?
... View more
01-16-2025
12:27 PM
1 Like
Yes, in fact, I do know HOW. I wrote SASPy 🙂
And, I've had to enhance how I was doing that a couple of times over the years to account for SAS idiosyncrasies, like having text between the ERROR and the :, and for cases where logging has been enhanced by the user such that the log contains other formatted content, like timestamps and pids and stuff either before or after the SAS log output - so ERROR isn't even in column 1 of the log I get back. Lots of crazy stuff.
Here's the check: if re.search(r'\nERROR[ \d-]*:', logd): warnings.warn("Noticed 'ERROR:' in LOG, you ought to take a look and see if there was a problem") self._sb.check_error_log = True
Unfortunately, SAS was never completely consistent, like a regular programming language where you call a function and check a return code, regarding programmatically being able to asses the results from submitted code. As others have mentioned, sometimes you can see ERROR: in the log and there wasn't really an error that kept things from working. Sometimes something doesn't work and you don't get ERROR. WARNING can't preclude something not working, or prove it did. The system Macros like SYSERR SYSINFO and all the others, aren't 100% reliable. All that.
So, I try my best to provide these things so you can have the best chance of programmatically assessing your code. The best advice may be to only submit 1 SAS step of code at a time and use whichever method (Error check, Macro, ...) that works best for assessing that step, instead of submitting a whole program full of stuff and trying to assess all of it. Note you can also do things like, after a data step, check to see if the table exists and it has the number of rows expected.
SASPy is used in house for testing and that testing is automated and self assessing, using these various means to assess whether the code passed or failed. I wish there was simply one return code you could check for any SAS code you submit, but there isn't.
Tom
... View more
01-16-2025
10:32 AM
Yes, a firewall can cause that problem. Do you have a computer at home, or not behind the corporate firewall to just try? Or do you have IT that can help with that?
... View more
01-13-2025
04:05 PM
The firewall thought is a good one. What's strange is that for various failures I can cause, they all provide some error message between what you had:
We failed in getConnection
SAS process has terminated unexpectedly. RC from wait was: 4294967290
for instance, providing the wrong machine name:
>>> sas = saspy.SASsession(cfgname='oda', iomhost='bob')
We failed in getConnection The application could not log on to the server "bob:8591". The machine name is not valid.
SAS process has terminated unexpectedly. RC from wait was: 4294967290
Since there is no actual error message coming back, it's likely you aren't getting to the ODA system. Since you're failing where you are, it seems Java is valid and found and starting up. So, I think looking into something like 'you can't get there from here' is the next step. Can you connect to ODA using other means like studio or EG from the same client machine?
... View more
01-13-2025
03:54 PM
1 Like
Also, you can access the SAS automatic macro variables as needed to check them: https://sassoftware.github.io/saspy/api.html#saspy.sasbase.SASsession.SYSERR
as well as any macro variable using symget().
... View more
01-13-2025
03:50 PM
1 Like
take a look at this part of the doc and see if it answers your question: https://sassoftware.github.io/saspy/advanced-topics.html#automatic-checking-for-error-in-the-log-and-the-warnings-module
... View more
12-03-2024
01:34 PM
Well, that's sort of more confusing. If you could run the following, it would help. And, there must be a lot more going on here because sd2df doesn't create parquet files. SAS only has Numeric or Character fields. Numerics can be augmented by assigning formats to them that say to interpret them as data/time/datetime (seconds or days from a point in time; but they are just numbers). So the information I asked for would help a lot, as I'm clearly missing a bunch of whatever is going on.
>>> sd = sas.sasdata(tablename, libref) >>> sd.columnInfo()
>>> df = sd.to_df() >>> df.info()
Thanks,
Tom
... View more
12-03-2024
10:14 AM
Well, I don't know why someone wanted all of the data returned as strings. But that looks like what it's doing. If you don't override what I do, then you should get the correct results, based upon what the SAS data set has for it's variables. Can you submit the following and show the results (replacing the table/libref with yours, of course), so I can have some idea of what the variables are?
Is there some column that isn't coming across correctly if you remove the dtype= and my_formats= from your sd2df call? Is there any clue as to why everything was being brought over as strings? And again, the link in the doc I posted previously explains how/why you would use this to override, but only when you want things different then the default.
>>> sd = sas.sasdata('cars','sashelp') >>> sd.columnInfo() Member Num Variable Type Len Pos Format Label 0 SASHELP.CARS 9.0 Cylinders Num 8.0 24.0 NaN NaN 1 SASHELP.CARS 5.0 DriveTrain Char 5.0 147.0 NaN NaN 2 SASHELP.CARS 8.0 EngineSize Num 8.0 16.0 NaN Engine Size (L) 3 SASHELP.CARS 10.0 Horsepower Num 8.0 32.0 NaN NaN 4 SASHELP.CARS 7.0 Invoice Num 8.0 8.0 DOLLAR8. NaN 5 SASHELP.CARS 15.0 Length Num 8.0 72.0 NaN Length (IN) 6 SASHELP.CARS 11.0 MPG_City Num 8.0 40.0 NaN MPG (City) 7 SASHELP.CARS 12.0 MPG_Highway Num 8.0 48.0 NaN MPG (Highway) 8 SASHELP.CARS 6.0 MSRP Num 8.0 0.0 DOLLAR8. NaN 9 SASHELP.CARS 1.0 Make Char 13.0 80.0 NaN NaN 10 SASHELP.CARS 2.0 Model Char 40.0 93.0 NaN NaN 11 SASHELP.CARS 4.0 Origin Char 6.0 141.0 NaN NaN 12 SASHELP.CARS 3.0 Type Char 8.0 133.0 NaN NaN 13 SASHELP.CARS 13.0 Weight Num 8.0 56.0 NaN Weight (LBS) 14 SASHELP.CARS 14.0 Wheelbase Num 8.0 64.0 NaN Wheelbase (IN) >>> df = sd.to_df() >>> df.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 428 entries, 0 to 427 Data columns (total 15 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Make 428 non-null object 1 Model 428 non-null object 2 Type 428 non-null object 3 Origin 428 non-null object 4 DriveTrain 428 non-null object 5 MSRP 428 non-null float64 6 Invoice 428 non-null float64 7 EngineSize 428 non-null float64 8 Cylinders 426 non-null float64 9 Horsepower 428 non-null float64 10 MPG_City 428 non-null float64 11 MPG_Highway 428 non-null float64 12 Weight 428 non-null float64 13 Wheelbase 428 non-null float64 14 Length 428 non-null float64 dtypes: float64(10), object(5) memory usage: 50.3+ KB >>>
... View more
12-03-2024
09:29 AM
1 Like
Hey, I can help you with this. But, I'm not completely sure what you have going on here. Can you show me the code you're running and the proc contents output of the table in question? sd2df already figures out the types on the SAS data set to then create the corresponding data frame types. dtype= and my_formats= and formats= are for overriding the defaults when you want to transfer data over as something else, and they need to be specified so that your override produces the correct results. Again, I need a little more details on what you're actually doing, but the last example in the doc here (https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques) may provide you with an answer. Can you show me what you're doing and the table info, and then I can be more helpful.
Thanks!
Tom
... View more
10-23-2024
04:21 PM
1 Like
I would start here since I don't really know what your client nor SAS deployment is:
https://sassoftware.github.io/saspy/configuration.html#choosing-an-access-method
Then look at that section of the config doc for the specific Access Method.
... View more
10-23-2024
04:16 PM
https://sassoftware.github.io/saspy/index.html
... View more
trying some sample code from that doc on the FILESVC shows it is looking at the 'Drive' where I had uploaded my a.sas7bdat file. I guess I would have to copy it from there to WORK or something to access it via libname, but the file you were looking to get at was a csv, so filename would be what you want, not libname.
So if you upload it with the SAS Drive web page, then you can get at it from Jupyter via the filename FILERVC statement in your SAS code from any SAS session.
79 80 81 data _null_; 82 did = dopen('x'); 83 mcount = dnum(did); 84 put 'MYFLDR contains ' mcount 'member(s)...'; 85 do i=1 to mcount; 86 memname = dread(did, i); 87 put i @5 memname; 88 end; 89 rc = dclose(did); 90 run; MYFLDR contains 3 member(s)... 1 a.sas7bdat 2 SAS Videos 3 My Snippets NOTE: DATA statement used (Total process time): real time 0.77 seconds cpu time 0.33 seconds 91 92
... View more
Thanks Greg! @navdeepk that seems like it could be what you need. It seems to allow you to access the folder that you can't with the DISK access method (default for filename). Here's the assignment:
79 80 filename x filesrvc folderpath='/Users/sastpw/My Folder'; 81 filename x list; NOTE: Fileref= X Physical Name= /Users/sastpw/My Folder 82
... View more