BookmarkSubscribeRSS Feed
kaziumair
Quartz | Level 8

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;

fcmperror.PNG 

Thanks and Regards,

Mohammad Umair Kazi

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Your best chance might be to contact SAS tech support.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 534 views
  • 0 likes
  • 2 in conversation