@@ -11,9 +11,8 @@ Advanced topics
11
11
In this chapter we will explore more detailed explanations of specific functionality.
12
12
13
13
14
- ****************
15
14
Using Batch mode
16
- ****************
15
+ ================
17
16
18
17
Batch mode is meant to be used when you want to automate your code as Python scripts.
19
18
@@ -64,9 +63,8 @@ than this few lines of code, you can have the results updated and refreshed by j
64
63
re-running the script.
65
64
66
65
67
- *********
68
66
Prompting
69
- *********
67
+ =========
70
68
71
69
There are two types of prompting that can be performed; meaning to stop processing and
72
70
prompt the user for input and then resume processing.
@@ -188,9 +186,8 @@ at runtime for values you want to use in the code, and those values can be
188
186
kept around and used later in the code, or hidden and inaccessible afterward.
189
187
190
188
191
- ***************************************************************
192
189
Moving values between Python Variables and SAS Macro Variables
193
- ***************************************************************
190
+ ==============================================================
194
191
195
192
There are two methods on the SASsession object you can use to transfer values between Python and SAS.
196
193
symget() and symput(). To get a value from a SAS Macro Variable and assign it to a Python variable you
@@ -213,9 +210,8 @@ https://github.com/sassoftware/saspy-examples/blob/main/SAS_contrib/Using_SYMGET
213
210
214
211
215
212
216
- ********************************************************
217
213
Moving data between Python and SAS - datatype conversion
218
- ********************************************************
214
+ ========================================================
219
215
220
216
SASPy has methods to load data from a SAS Data Set (or View) into Python as a Pandas dataframe, as well
221
217
as the reverse; loading a dataframe into a SAS Data Set. This is all documented in the API doc and some
@@ -265,9 +261,8 @@ become missing values in SAS.
265
261
266
262
267
263
268
- **********************************
269
264
Dates, Times and Datetimes, Oh my!
270
- **********************************
265
+ ==================================
271
266
272
267
The sd2df and df2sd methods transfer data between SAS Data Sets and Pandas dataframes. For most
273
268
cases, if you start with a SAS dataset and import it to a dataframe, then send it back to SAS,
@@ -362,9 +357,8 @@ https://github.com/sassoftware/saspy-examples/blob/main/Issue_examples/Issue279.
362
357
363
358
364
359
365
- ***********************************
366
360
Advanced sd2df and df2sd techniques
367
- ***********************************
361
+ ===================================
368
362
369
363
The sd2df and df2sd methods transfer data between SAS Data Sets and Pandas dataframes. For most cases,
370
364
you don't need to specify extra options. But, there are extra options to cover a variety of specific
@@ -492,9 +486,8 @@ https://github.com/sassoftware/saspy/issues/279 to see where this fuctionality c
492
486
493
487
494
488
495
- ******************************************************************************
496
489
Slow performance loading SAS data into a Pandas DataFrame ( to_df(), sd2df() )
497
- ******************************************************************************
490
+ ==============================================================================
498
491
499
492
UPDATE!!!
500
493
@@ -538,9 +531,8 @@ and newlines, which Pandas can have parsing problem with reading CSV file create
538
531
539
532
540
533
541
- *****************************************************************
542
534
Slow performance loading a DataFrame into a SAS data set; df2sd()
543
- *****************************************************************
535
+ =================================================================
544
536
545
537
df2sd (dataframe2sasdata) has two main steps, which were both done internal to the method. The second is transferring the data
546
538
but the first is figureing out the necessary metadata to be able to correctly define the SAS Data Set being created. This requires
@@ -686,9 +678,8 @@ Here are a few example cases showing this.
686
678
687
679
688
680
689
- *****************************************************************************
690
681
Using Proc Iomoperate to find Object Spawner hosts and Workspace Server ports
691
- *****************************************************************************
682
+ =============================================================================
692
683
693
684
If you already use a client to connect to IOM servers, you may have the host and port to OMR
694
685
(the SAS Metadata Server), but not necessarily those of the Object Spawners or Workspace Servers.
@@ -782,9 +773,8 @@ convention for these is to use the 'Server context :' value as the config name.
782
773
to know which server you will be connecting to.
783
774
784
775
785
- **************************************************************
786
776
Disconnecting from an IOM session and reconnecting back to it.
787
- **************************************************************
777
+ ==============================================================
788
778
789
779
The IOM access method has the ability to disconnect from the workspace server and
790
780
reconnect to it (the same one); IF the reconnect setting is configured for that workspace
@@ -818,9 +808,8 @@ a single process, and each time a disconnect happens a new toke is created. But,
818
808
specific case, so it is now available.
819
809
820
810
821
- *******************************************************************
822
811
Configuring Grid Option Sets to have saspy run on a specific Queue.
823
- *******************************************************************
812
+ ===================================================================
824
813
825
814
Working with Grid Options Sets is documented here (the 'Doc' referred to below):
826
815
http://support.sas.com/documentation/cdl/en/gridref/67371/HTML/default/viewer.htm#n1inymfs0b7go2n147xdknz0ygpx.htm
@@ -847,9 +836,8 @@ in to the grid options mapping wizard (the first part of the document referenced
847
836
should now be available to choose and you can set this up as you want.
848
837
849
838
850
- ****************************************************************
851
839
Automatic checking for ERROR: in the LOG and the warnings module
852
- ****************************************************************
840
+ ================================================================
853
841
854
842
Based upon an enhancement request, as of version 3.6.7, SASPy now checks for 'ERROR:' and issues a message via the warnings module
855
843
to inform you that you should take a look at the log and see if there was a problem. SASPy methods won't blindly fail just by finding
@@ -964,9 +952,8 @@ Hopefully you will find this enhancement useful. It would be great if each thing
964
952
not the case. So, checking the log is something that's necessary sometimes. Hopefully this warning when an ERROR is seen, will make this easier.
965
953
966
954
967
- *********************************************
968
955
saspy.logger from logging.logger as of V3.7.5
969
- *********************************************
956
+ =============================================
970
957
971
958
Per a user request to get rid of using print() for variaous messages, and use the logging facility instead, I've
972
959
replaced all non-interactive prints() in saspy (print is still used for prompting, as it needs to be) with
@@ -1100,9 +1087,8 @@ Here's just a little example of a programm showing some of this.
1100
1087
1101
1088
1102
1089
1103
- ***************************************************
1104
1090
SASsession object as a context manager as of V3.7.5
1105
- ***************************************************
1091
+ ===================================================
1106
1092
1107
1093
A user contributed, via PR #401, the ability for a SASsession object to be used as a context manage
1108
1094
for the 'with' statement (see https://docs.python.org/3.9/reference/datamodel.html#context-managers).
@@ -1177,9 +1163,9 @@ Here's a live example showing that the Session was terminated after the with con
1177
1163
>>>
1178
1164
1179
1165
1180
- **************
1181
1166
Jupyter magics
1182
- **************
1167
+ ==============
1168
+
1183
1169
Jupyter Notebooks have what they call Magics, which let you submit code from a diferent language
1184
1170
than the kernel of the notebook, or provide other functionality. SASPy supports a few magics that
1185
1171
you can use if you are in a Jupyter Notebook. They simply allow you to submit explicit SAS code
0 commit comments