The PROC PYTHON procedure causes SAS to be suspended when processing graphics in SAS 9.4.M9. The plot is generated, but the SAS session is suspended.
Suspension of SAS occurs after the graph is created because the process never returns and does not execute any further statements. The following program replicates the issue.
For example, in the following example code following, the Print function is never executed:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.DataFrame({"Sex": ['Female', 'Female'], "AgeAtStart": [41,57]})
sns.histplot(data=df, x='AgeAtStart', hue='Sex',alpha=0.5,bins=15,kde=False,palette='Set2', multiple="stack")
print('Display text")
To work around this issue, use the matplotlib back-end "Agg". Matplotlib also offers other backend options. For more information, see Using Matplotlib ► Figures and backends ► Backends.
The following example modifies the previous one and uses the non-interactive matplotlib backend 'Agg':
import pandas as pd
import seaborn as sns
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
df = pd.DataFrame({"Sex": ['Female', 'Female'], "AgeAtStart": [41,57]})
sns.histplot(data=df, x='AgeAtStart', hue='Sex',alpha=0.5,bins=15,kde=False,palette='Set2', multiple="stack")
print('Display text")