Hi Everyone ,
I am trying to execute python code using PROC FCMP .
This is my first time using PROC FCMP .
When I execute the program I get an Import error stating that a module (pdfminer) I am using is not there.
I know that when this error occurs in python the module is missing and we need to install it.
Does anyone know where and how to install this module so that I can resolve this error?
Do I need to use the pip install command?
Please advise.
I have attached my code and error for your reference.
filename t temp;
proc printto print=t;
run;
/* A basic example of using PROC FCMP to execute a Python function */
proc fcmp;
/* Declare Python object */
declare object py(python);
/* Create an embedded Python block to write your Python function */
submit into py;
def extractlink():
"Output: mytable"
from io import StringIO
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfparser import PDFParser
import requests
from bs4 import BeautifulSoup
import pandas as pd
links = []
headline = []
article_content=[]
subset_links=[]
page=requests.get('https://www.statecapture.org.za/site/media/statements')
soup=BeautifulSoup(page.content,'html.parser')
urls=soup.find_all("a",class_="text-uppercase")
for a in soup.find_all("a",class_="text-uppercase", href=True):
if a.text:
links.append({
'url':a['href'],
'headline':a.text.replace('\xa0','')
})
mytable=pd.DataFrame(links)
return mytable
endsubmit;
/* Publish the code to the Python interpreter */
rc = py.publish();
/* Call the Python function from SAS */
rc = py.call("extractlink");
/* Store the result in a SAS variable and examine the value */
SAS_Out = py.results["mytable"];
put SAS_Out=;
run;
proc printto;
run;
data _null_;
infile t;
input;
put _infile_;
run;
filename t;
Thanks and Regards,
Mohammad Umair Kazi
Your best chance might be to contact SAS tech support.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.