Developers

8月 072021
 

I'm excited to curate a series of posts focused on CAS Actions. However, before I dive into details and code, I thought I'd take a moment to lay a foundation for a better understanding of CAS and CAS actions. I'll cover things here at a high level as there's quite a bit of information out there already. Please see the Additional Resources section at the end of this article for more details.

CAS actions are highly optimized units of work for SAS Viya's Cloud Analytics Services (CAS) distributed computing engine. Think of CAS actions as powerful functions or methods created specifically to process data in the CAS server. Actions can load data, manage tables, perform general analytics, statistics, and machine learning, as well as execute DATA step, FedSQL, DS2 and more. Did I mention they can do a lot?

Before we dive into details about actions, let's quickly review the CAS server in SAS Viya.

CAS Server

First, the CAS Server. It provides cloud-based, run-time environment for data management and analytics in SAS Viya. You process data in all stages of the analytic life cycle using the power of distributing computing. To process data in the CAS server, you must first load data into memory from a data source.

Data Sources

Data sources connect to the CAS server through caslibs. Caslibs can access a wide variety of data sources including relational databases, streaming data, SAS data sets, unstructured data, and familiar file formats, such as XML, JSON, CSV, and XLSX.

CAS Actions

Once you have data available in the CAS server you can begin to process it using CAS actions. Actions are the native language of the CAS server. All actions are aggregated with other actions in action sets. You can think of an action set as a package, and the actions inside an action set as methods. There are dozens of CAS action sets and hundreds of CAS actions available.

Executing Actions

There are a variety of interfaces available to execute CAS actions. One method is using the native CAS Language (CASL). CASL is a statement based scripting language. With CASL you can use general programming logic to execute actions, work with the results, and develop analytic pipelines. You can also execute actions through the CAS API using languages like SAS, FedSQL, Python, R, Java, Lua and REST.

Using Familiar Language Methods

One major benefit of CAS actions is the CAS API allows you to execute familiar syntax in your language of choice. When using familiar methods, the CAS API will convert them into actions behind the scenes.

For example, to retrieve the first ten rows of a CAS table you can use the SAS PRINT procedure, the Python head method, or the R head function. All of these methods will convert to the fetch action behind the scenes through the CAS API. Many familiar procedures, methods and functions are available. See the SAS Viya Programming for Developers documentation for more details about specific languages.

NOTE: THE SWAT package is required to use Python and R with the CAS server.

Executing Actions in a Variety of Languages

Another benefit of CAS actions is that you can directly execute actions from a variety of languages. This allows for all types of programmers to work together using common actions. For example, you can execute the same fetch action in SAS, R and Python.

NOTE: THE SWAT package is required to use Python and R with the CAS server.

SAS Viya Applications

Lastly, SAS Viya has a many applications that can work with data in the CAS server, These applications provide a variety of functionality. From point and click to programming, executing actions behind the scenes.

Summary

Hopefully, I've provide enough of a base for CAS, CAS actions, and CAS action sets for you to get started. Here's what you need to know to move forward:

  • SAS Viya's CAS server is a powerful distributed comping engine that processes big data fast.
  • CAS actions are the native language of the CAS server.
  • CAS actions can be executed in a variety of languages like CASL, SAS, Python, R, Lua, Java and REST.
  • SAS Viya has additional applications to work with CAS data.

Additional Resources

SAS® Cloud Analytic Services: Fundamentals
The Architecture of the SAS® Cloud Analytic Services in SAS® Viya™
What is CASL?
SAS Viya Programming examples on GitHub
Using SAS Cloud Analytics Service REST APIs to run CAS Actions
SAS Developers Portal
SAS Developers Community

CAS Actions and Action Sets - a brief intro was published on SAS Users.

8月 072021
 

I'm excited to bring a series of posts centered on CAS Actions. The topics in the list below will be covered in posts set to publish in the next few weeks. Please check back often for new releases.

CAS Actions and Action Sets - a brief intro
CAS-Action! fetch CAS, fetch! - Part 1
CAS-Action! fetch CAS, fetch! - Part 2
CAS-Action! Show me the ColumnInfo!
CAS-Action! Simply Distinct - Part 1
CAS-Action! Simply Distinct - Part 2
CAS-Action! executing SQL in CAS

CAS Action! - a series on fundamentals was published on SAS Users.

6月 232021
 

Welcome to the fifth installment in my series Getting Started with Python Integration to SAS Viya. In previous posts, I discussed how to connect to the CAS server, how to execute CAS actions, how to work with the results, and how your data is organized on the CAS server. In this post I'll discuss loading files into the CAS server. Before proceeding, I need to clear up some terminology. There are two sources for loading files into memory, server-side and client-side. It's important to understand the difference.

Server-Side vs Client-Side

Let's start off with an image depicting server- and client-side file locations.

Server-side files are mapped to a caslib. That is, files in the data source portion of a caslib are server-side. For more infomation on data sources, see Part 4 of this series. Client-side files are files that are not mapped to a caslib. These could be files stored in a SAS library or other local files. That's about it!

In this post, I'll focus on loading server-side files into memory (Part 6 of the series will cover client-side files). In Python, we have two data loading options, the loadTable CAS action, or the load_path method. The techniques are almost identical. The difference is the loadTable action returns a dictionary of information and the load_path method returns a CASTable. If you use the loadTable action you must reference a new table in a separate step. In general, I prefer the actions as they are available in any language such as CASL, R, and Python. Conversely, methods like load_path are specific to a language.

Let's look at a few examples of loading different types of datafiles into CAS.

Loading a SAS Data Set into Memory

In the first example, I want to load the cars.sas7bdat SAS data set from the casuser caslib into memory. Let's confirm the table exists in the caslib by executing the fileInfo action. I made my connection to CAS, naming it conn. For more information about making a connection to CAS, visit Part 1 of the series.

conn.fileInfo(caslib="casuser")

In the results I can see that the cars.sas7bdat file is available in the casuser caslib.

Next, I'll use the loadTable action. First I'll specify the path parameter with the full file name, then the caslib parameter specifying the input caslib, and lastly the casOut parameter to specify the new CAS table. In the casOut parameter you specify a dictionary of key value pairs. Here, I want to name the new table cars_sas and place the table in the casuser caslib.

conn.loadTable(path="cars.sas7bdat", caslib="casuser",
               casOut={
                       "name":"cars_sas",
                       "caslib":"casuser"
               })

After executing the loadTable action, the result returns a dictionary of information about the new table.

Now that the file is loaded into memory, I can process the data by making a reference to the in-memory table using the CASTable method. Then I'll use the head method to view the first 5 rows.

cars = conn.CASTable("cars_sas",caslib="casuser")
cars.head()

Loading a CSV file into Memory

In the next example, I'll load a CSV file into memory. Even though it's a different file type, we still use the loadTable action. The only change needed is the file name in the path parameter. That's it!

conn.loadTable(path="cars.csv", caslib="casuser",
           casOut={
                "name":"cars_csv",
                "caslib":"casuser"
           })
 
csv = conn.CASTable("cars_csv", caslib="casuser")
csv.head()

 

Loading a Text file into Memory

Lastly, data is not always stored in the correct format. Sometimes when loading files you need to modify the default parameters. In this final scenario, let's explore an example using the importOptions parameter. importOptions takes a variety of key value pairs as the values to dictate how to load the file. The options vary depending on the file type.

The file in this example contains no column names, and the delimiter is a vertical bar (or pipe).

I'll begin with specifying the column names in a variable named colNames. Then, in the loadTable action I'll add the importOptions parameter and specify the following:

  • file type I want to import, using the fileType subparameter,
  • the delimiter, using the delimiter subparameter,
  • the getNames subparameter with the value False, since no column names exist,
  • and lastly, the vars subparameter with the names of the columns.

And as in the previous examples, I'll print out the first five lines of the resulting table from memory.

colNames=['Make', 'Model', 'Type', 'Origin', 'DriveTrain', 'MSRP', 'Invoice',
          'EngineSize', 'Cylinders', 'Horsepower', 'MPG_City', 'MPG_Highway',
          'Weight', 'Wheelbase', 'Length']
 
conn.loadTable(path="cars_delim_bar.txt", caslib="casuser",
           casOut={
                "name":"cars_text",
                "caslib":"casuser"
           },
           importOptions={"fileType":"DELIMITED",
                          "delimiter":"|",
                          "getNames":False,
                          "vars":colNames}
          )
 
csv = conn.CASTable("cars_text", caslib="casuser")
csv.head()

Summary

The loadTable action is flexible and an easy way to load tables into memory. Benefits of the loadTable action include:

  • it's filetype agnostic
  • has many options available based on the file types being imported into memory
  • available in any CAS-compatible language like Python, R and CASL with slight changes to the syntax based on the language used

 

Additional and related resources

Getting Started with Python Integration to SAS® Viya® - Part 5 - Loading Server-Side Files into Memory was published on SAS Users.

6月 232021
 

Welcome to the fifth installment in my series Getting Started with Python Integration to SAS Viya. In previous posts, I discussed how to connect to the CAS server, how to execute CAS actions, how to work with the results, and how your data is organized on the CAS server. In this post I'll discuss loading files into the CAS server. Before proceeding, I need to clear up some terminology. There are two sources for loading files into memory, server-side and client-side. It's important to understand the difference.

Server-Side vs Client-Side

Let's start off with an image depicting server- and client-side file locations.

Server-side files are mapped to a caslib. That is, files in the data source portion of a caslib are server-side. For more infomation on data sources, see Part 4 of this series. Client-side files are files that are not mapped to a caslib. These could be files stored in a SAS library or other local files. That's about it!

In this post, I'll focus on loading server-side files into memory (Part 6 of the series will cover client-side files). In Python, we have two data loading options, the loadTable CAS action, or the load_path method. The techniques are almost identical. The difference is the loadTable action returns a dictionary of information and the load_path method returns a CASTable. If you use the loadTable action you must reference a new table in a separate step. In general, I prefer the actions as they are available in any language such as CASL, R, and Python. Conversely, methods like load_path are specific to a language.

Let's look at a few examples of loading different types of datafiles into CAS.

Loading a SAS Data Set into Memory

In the first example, I want to load the cars.sas7bdat SAS data set from the casuser caslib into memory. Let's confirm the table exists in the caslib by executing the fileInfo action. I made my connection to CAS, naming it conn. For more information about making a connection to CAS, visit Part 1 of the series.

conn.fileInfo(caslib="casuser")

In the results I can see that the cars.sas7bdat file is available in the casuser caslib.

Next, I'll use the loadTable action. First I'll specify the path parameter with the full file name, then the caslib parameter specifying the input caslib, and lastly the casOut parameter to specify the new CAS table. In the casOut parameter you specify a dictionary of key value pairs. Here, I want to name the new table cars_sas and place the table in the casuser caslib.

conn.loadTable(path="cars.sas7bdat", caslib="casuser",
               casOut={
                       "name":"cars_sas",
                       "caslib":"casuser"
               })

After executing the loadTable action, the result returns a dictionary of information about the new table.

Now that the file is loaded into memory, I can process the data by making a reference to the in-memory table using the CASTable method. Then I'll use the head method to view the first 5 rows.

cars = conn.CASTable("cars_sas",caslib="casuser")
cars.head()

Loading a CSV file into Memory

In the next example, I'll load a CSV file into memory. Even though it's a different file type, we still use the loadTable action. The only change needed is the file name in the path parameter. That's it!

conn.loadTable(path="cars.csv", caslib="casuser",
           casOut={
                "name":"cars_csv",
                "caslib":"casuser"
           })
 
csv = conn.CASTable("cars_csv", caslib="casuser")
csv.head()

 

Loading a Text file into Memory

Lastly, data is not always stored in the correct format. Sometimes when loading files you need to modify the default parameters. In this final scenario, let's explore an example using the importOptions parameter. importOptions takes a variety of key value pairs as the values to dictate how to load the file. The options vary depending on the file type.

The file in this example contains no column names, and the delimiter is a vertical bar (or pipe).

I'll begin with specifying the column names in a variable named colNames. Then, in the loadTable action I'll add the importOptions parameter and specify the following:

  • file type I want to import, using the fileType subparameter,
  • the delimiter, using the delimiter subparameter,
  • the getNames subparameter with the value False, since no column names exist,
  • and lastly, the vars subparameter with the names of the columns.

And as in the previous examples, I'll print out the first five lines of the resulting table from memory.

colNames=['Make', 'Model', 'Type', 'Origin', 'DriveTrain', 'MSRP', 'Invoice',
          'EngineSize', 'Cylinders', 'Horsepower', 'MPG_City', 'MPG_Highway',
          'Weight', 'Wheelbase', 'Length']
 
conn.loadTable(path="cars_delim_bar.txt", caslib="casuser",
           casOut={
                "name":"cars_text",
                "caslib":"casuser"
           },
           importOptions={"fileType":"DELIMITED",
                          "delimiter":"|",
                          "getNames":False,
                          "vars":colNames}
          )
 
csv = conn.CASTable("cars_text", caslib="casuser")
csv.head()

Summary

The loadTable action is flexible and an easy way to load tables into memory. Benefits of the loadTable action include:

  • it's filetype agnostic
  • has many options available based on the file types being imported into memory
  • available in any CAS-compatible language like Python, R and CASL with slight changes to the syntax based on the language used

 

Additional and related resources

Getting Started with Python Integration to SAS® Viya® - Part 5 - Loading Server-Side Files into Memory was published on SAS Users.

6月 182021
 

Welcome to the fourth installment in my series Getting Started with Python Integration to SAS Viya. In previous posts, I discussed how to connect to the CAS server, how to execute CAS actions, and how to work with the results. Now it's time to understand how your data is organized on the CAS server. To understand how the data is catalogued you must understand caslibs.

So the big question is, "What exactly is a caslib?"

Caslib Overview

Let's start with an image as an introduction to caslibs.

A caslib contains connection information about a data source and an in-memory space to process data. A caslib also contains session information and a variety of access controls for users and scope. In this post I'll focus on exploring the in-memory and data source portion of a caslib.

  • The data source portion holds information about the caslib such as the path that holds a variety of data files like xlsx, sas7bdat, csv, txt, or sashdat. It can also represent a database connection.
  • The in-memory portion contains data source files loaded into memory and available for distributed processing as CAS tables.

For detailed information about caslibs, visit the SAS documentation.

Exploring Caslibs

Let's look at an example. You can follow along by logging into SAS Viya and making a connection to the CAS server with your Python client. I will be using SAS Viya for Learners (using the Jupyter Notebook option), and have already made my connection to CAS and named my connection conn. For more information about making a connection to CAS, visit Part 1 of the series.

After making a connection to CAS, use the caslibInfo CAS action to view the available caslibs.

conn.caslibInfo()

The result of the caslibInfo action returns a table, as seen above. The table includes the name of each caslib, it's type, a description, and the path. The table also includes a caslib metadata:

  • The Local column indicates the scope of the caslib. A 0 represents a global caslib, and a 1 is local.
  • The Active column indicates if the caslib is active. A 1 represents an active caslib. If a CAS action has no caslib specified, the active caslib is used.
  • The Personal column indicates if the caslib is only available to you. By default, all users get a casuser caslib, only accessible by that user.

View Available Data Source Files in a Caslib

Next, let's view the data source files in the casuser caslib. Data source files are physical files available to the CAS server. These are known as server-side files since they are associated with a caslib.

To view the available data source files, use the fileinfo action with the caslib parameter. Note, if you do not use the caslib parameter, the fileinfo action uses the active caslib.

conn.fileInfo(caslib="casuser")

The results of the fileInfo action show that my casuser caslib's data source portion contains csv, txt and sas7bdat files.

View Available In-Memory Tables in a Caslib

Now, let's see if any tables are loaded into memory. To view available in-memory tables, use the tableinfo action with the caslib parameter.

conn.tableinfo(caslib="casuser")

The results of the tableInfo action show one table named CARS loaded into memory. Once a table is loaded into the in-memory portion, you can begin processing the data. Here I'll make a reference the CARS CAS table using the CASTable method. Then I'll use the head method to view the first 5 rows of the table.

cars=conn.CASTable("CARS", caslib="casuser")
cars.head()

The results of the head method show the first 5 rows of the CARS table.

Summary

In conclusion, the most important concept to understand about caslibs are the two main areas: data source and in-memory. The former contains connection information to a data source and the latter refers to CAS tables available for processing. Using the actions above, you can easily explore the data in your environment.

In Part V of the series, we'll look at loading data into memory. Stay tuned.

Additional and related resources:

Getting Started with Python Integration to SAS® Viya® - Part 4 - Exploring Caslibs was published on SAS Users.

5月 112021
 

It’s safe to say that SAS Global Forum is a conference designed for users, by users. As your conference chair, I am excited by this year’s top-notch user sessions. More than 150 sessions are available, many by SAS users just like you. Wherever you work or whatever you do, you’ll find sessions relevant to your industry or job role. New to SAS? Been using SAS forever and want to learn something new? Managing SAS users? We have you covered. Search for sessions by industry or topic, then add those sessions to your agenda and personal calendar.

Creating a customizable agenda and experience

Besides two full days of amazing sessions, networking opportunities and more, many user sessions will be available on the SAS Users YouTube channel on May 20, 2021 at 10:00am ET. After you register, build your agenda and attend the sessions that most interest you when the conference begins. Once you’ve viewed a session, you can chat with the presenter. Don’t know where to start? Sample agendas are available in the Help Desk.

For the first time, proceedings will live on SAS Support Communities. Presenters have been busy adding their papers to the community. Everything is there, including full paper content, video presentations, and code on GitHub. It all premiers on “Day 3” of the conference, May 20. Have a question about the paper or code? You’ll be able to post a question on the community and ask the presenter.

Want training or help with your code?

Code Doctors are back this year. Check out the agenda for the specific times they’re available and make your appointment, so you’ll be sure to catch them and get their diagnosis of code errors. If you’re looking for training, you’ll be quite happy. Training is also back this year and it’s free! SAS instructor-led demos will be available on May 20, along with the user presentations on the SAS Users YouTube channel.

Chat with attendees and SAS

It is hard to replicate the buzz of a live conference, but we’ve tried our best to make you feel like you’re walking the conference floor. And we know networking is always an important component to any conference. We’ve made it possible for you to network with colleagues and SAS employees. Simply make your profile visible (by clicking on your photo) to connect with others, and you can schedule a meeting right from the attendee page. That’s almost easier than tracking down someone during the in-person event.

We know the exhibit hall is also a big draw for many attendees. This year’s Innovation Hub (formerly known as The Quad) has industry-focused booths and technology booths, where you can interact in real-time with SAS experts. There will also be a SAS Lounge where you can learn more about various SAS services and platforms such as SAS Support Communities and SAS Analytics Explorers.

Get started now

I’ve highlighted a lot in this blog post, but I encourage you to view this 7-minute Innovation Hub video. It goes in depth on the Hub and all its features.

This year there is no reason not to register for SAS Global Forum…and attend as few or as many sessions as you want. Why? Because the conference is FREE!

Where else can you get such quality SAS content and learning opportunities? Nowhere, which is why I encourage you to register today. See you soon!

SAS Global Forum: Your experience, your way was published on SAS Users.

4月 202021
 

I can’t believe it’s true, but SAS Global Forum is just over a month away. I have some exciting news to share with you, so let’s start with the theme for this year:

New Day. New Answers. Inspired by Curiosity.

What a fitting theme for this year! Technology continues to evolve, so each new day is a chance to seek new answers to what can sometimes feel like impossible challenges. Our curiosity as humans drives us to seek out better ways to do things. And I hope your curiosity will drive you to register for this year’s SAS Global Forum.

We are excited to offer a global event across three regions. If you’re in the Americas, the conference is May 18-20. In Asia Pacific? Then we’ll see you May 19-20. And we didn’t forget about Europe. Your dates are May 25-26. We hope these region-specific dates and the virtual nature of the conference means more SAS users than ever will join us for an inspiring event. Curious about the exciting agenda? It’s all on the website, so check it out.

Keynotes speakers that you’ll talk about for months to come

Want to be inspired to chase your “impossible” dreams? Or hear more about the future of AI? How about learning about work-life balance and your mental health? We have you covered. SAS executives are gearing up to host an exciting lineup of extremely smart, engaging and thought-provoking keynote speakers like Adam Grant, Ayesha Khanna and Hakeem Oluseyi.

And who knows, we might have a few more surprises up our sleeve. You’ll just have to register and attend to find out.

Papers and proceedings: simplified and easy to find

Have you joined the SAS Global Forum online community? You should, because that’s where you’ll find all the discussion around the conference…before, during and after. It’s also where you’ll find a link to the 2021 proceedings, when they become available. Authors are busy preparing their presentations now and they are hard at work staging their proceedings in the community. Join the community so you can connect with other attendees and know when the proceedings become available.

Stay tuned for even more details

SAS Global Forum is the place where creativity meets curiosity, and amazing analytics happens! I encourage you to regularly check the conference website, as we’re continually adding new sessions and events. You don’t want to miss this year’s conference, so don’t forget to register for SAS Global Forum. See you soon!

Registration is open for a truly inspiring SAS Global Forum 2021 was published on SAS Users.

3月 252021
 

Readers of my earlier post Discover Visual Analytics Report Paths with REST APIs asked for ways to export SAS Visual Analytics (VA) report content programmatically. I know this is a topic of interest from many VA report designers. So, I think it’s better to write something on this and I hope this post can be of help for such requirements.

We all know SAS Visual Analytics provides ability to export reports to PDF in the product GUI. In addition, the REST API for visualization also provides APIs to save the entire report or report objects to SVG image. In this article, I will use the SAS VA SDK to export VA reports to a PDF file. Note: this task requires some basic knowledge with JavaScript programming; good thing is, it’s not that complicated.

The SAS VA SDK provides a set of components and APIs that enable you to render anything from the entire report down to individual report parts. I am going to show how to export VA report content to a PDF document.

The VA SDK requires several prerequisites be set up in SAS Viya. These steps are covered in the documentation and I’ll not detail them here. For reference, these may include enabling CORS, CSRF, HTTPS and Cross-site cookies. Also, the VA SDK provides options to connect to SAS Viya using 'credentials' or 'guest' authentication. If you want to have the report accessible by the 'guest' user, it needs the

<script async src="https://unpkg.com/@sassoftware/va-report-components@latest/dist/umd/va-report-components.js"></script>

*Note: I am using va-report-components@latest above to invoke the latest available version of SDK library. You may also indicate a specific version, such as @0.14.0 for version 0.14.0 of the SDK library.

Get the VA report URI

If you are not familiar with how to get the reportUri, refer to the 'Get the ReportURI' section in the Using REST API to transform a Visual Analytics Report post. In this example I received the following response to my API call: reportUri=/reports/reports/cbf97b0a-457d-4b4f-8913-547e0cdf390c.

Display the VA report in the web page

This can be done by embedding an HTML custom tag in the section of your web page. The VA SDK supports three types of HTML custom tags: the entire report, a report page, or individual report objects. Each type is introduced below.

  1. <sas-report>
  2. In the sample code below, the URL represents the SAS Viya server, the authenticationType is 'guest' or 'credentials', and the reportUri identifies the report to render.

            <sas-report
                authenticationType="guest"
                url="http://sas-viya-server.com"
                reportUri="/reports/reports/c3c6befb-3981-4c9e-b011-7dc11dec5e37">
            </sas-report>
  3. <sas-report-page>
  4. In the sample code below, the URL represents the SAS Viya server, the authenticationType is ‘guest’ or ‘credentials’, the reportUri identifies the report, and the pageName indicates which page within the report to render. You can use and actual page number or use pageIndex="0" which refers to the first page in the report. You can get the tag in SAS Visual Analytics, by clicking the 'Copy link…' menu item from the context menu of the page, choosing the 'Embeddable web component' option and clicking the 'Copy Link' button.

            <sas-report-page
                authenticationType="credentials"
                url="http://sas-viya-server.com"
                reportUri="/reports/reports/c3c6befb-3981-4c9e-b011-7dc11dec5e37"
                pageName="vi20">
          </sas-report-page>
  5. <sas-report-object>
  6. In the sample code below, the URL represents the SAS Viya server, the authenticationType is 'guest' or 'credentials', the reportUri identifies the report, and the objectName gives the name of the object in VA report to render. You can get the tag in SAS Visual Analytics, by clicking the 'Copy link…' menu item from the context menu of any an object, choosing the 'Embeddable web component' option and clicking the 'Copy Link' button.

            <sas-report-object
                authenticationType="guest"
                url="http://sas-viya-server.com"
                reportUri="/reports/reports/c3c6befb-3981-4c9e-b011-7dc11dec5e37"
                objectName="ve27">
            </sas-report-object>

Make a function to export PDF

Remember when I said you’d need a little JavaScript knowledge? Well, the time is now. Follow the steps below to create a function in JavaScript which exports the report, page or object to a PDF file.

  1. Load the global vaReportComponents from SDK library. This is done by the window.addEventListener('vaReportComponents.loaded', function()) function.
  2. Next, get the report handle by calling the getReportHandle method on an object given by one type of three custom HTML tags. Something like myReport.getReportHandle(), myReportPage.getReportHandle(), or myReportObject.getReportHandle().
  3. Invoke the reportHandle.exportPDF(options) function to export the PDF. The options give the customized properties of the exported report. If no option is specified, the default value for the options is used. For example, the options can have the 'includeCoverPage: false' which means the exported PDF will not generate the cover page for the report. There are multiple options for the exportPDF function, please refer the VA SDK document for more info and its usage.

Put all together

Below are the snippets to generate the PDF document for a report page, using the options of no cover page and no appendix.

  1. I put a button in the HTML page, so I can click the button to trigger the export PDF function.
  2. The page displays the report page I am going to export. I’ve added id="sasReportPage" in the sas-report-page html tag, so I can get the DOM element by its ID quickly using the document.getElementById("sasReportPage") method.
  3. <html>
    <head> <meta http-equiv="content-Type" content="text/html"> 
    <script async src="https://unpkg.com/@sassoftware/va-report-components@latest/dist/umd/va-report-components.js"></script>
    </head>
     
    <body>
    <div id="buttons"> Export the PDF document of the VA report page by clicking the 
    <button type="button" class="btn_load" id ="PrintBtn" onclick="PrintPDF()"> EXPORT PDF </button> button. </div>
    <div >
            <sas-report-page id="sasReportPage"
                authenticationType="credentials" 
                url="https://sas-viya.com" 
                reportUri="/reports/reports/cbf97b0a-457d-4b4f-8913-547e0cdf390c" pageIndex=0>
        </sas-report-pag>
    </div>
    <script>
        function PrintPDF() {
    		// load the global variable of vaReportComponents
                document.addEventListener('vaReportComponents.loaded', function(){});
                const myReport = document.getElementById("sasReportPage");
    		// get the report page handle
            myReport.getReportHandle().then((reportHandle) => {
    	  	    // set options – not include cover page and appendix of the report
    const options = {
                          includeCoverPage: false,
                          includeAppendix: false,
                   includedReportObjects: ["vi6"],
                };
     
    	   	    // call the exportPDF function to export PDF document
                reportHandle.exportPDF(options).then((pdfUrl) => {
                          // Open the exported PDF in a new window
                      window.open(pdfUrl, '_blank');
            });
            });
    }
    </script>
    </body>
    </html>
  4. Save the code above as an html page, so I can access it from a web server. For example, save to my localhost/myproj/mysdk.html. When I load the page successfully, it shows the VA report page embedded in my html page as below:
  5. VA report page embedded in my html page

  6. Now, clicking the 'EXPORT PDF' button, opens a new page with exported PDF document like below:
  7. Exported PDF document

Summary

In this post, we’ve learned how to use the SAS VA SDK to call reports, display them in a web page and export them to a PDF file. In the sample snippets, I used the sas-report-page html tag to export one page of a VA report. Change the html tag to sas-report accordingly, and you can easily export the whole VA report, or change it to sas-report-object to export an object in the VA report.

Programmatically export Visual Analytics a report to PDF was published on SAS Users.

2月 252021
 

The people, the energy, the quality of the content, the demos, the networking opportunities…whew, all of these things combine to make SAS Global Forum great every year. And that is no exception this year.

Preparations are in full swing for an unforgettable conference. I hope you’ve seen the notifications that we set the date, actually multiple dates around the world so that you can enjoy the content in your region and in your time zone. No one needs to set their alarm for 1:00am to attend the conference!

Go ahead and save the date(s)…you don’t want to miss this event!

Content, content, content

We are working hard to replicate the energy and excitement of a live conference in the virtual world. But we know content is king, so we have some amazing speakers and content lined up to make the conference relevant for you. There will be more than 150 breakout sessions for business leaders and SAS users, plus the demos will allow you to see firsthand the innovative solutions from SAS, and the people who make them. I, for one, am looking forward to attending live sessions that will allow attendees the opportunity to ask presenters questions and have them respond in real time.

Our keynote speakers, while still under wraps for now, will have you on the edge of your seats (or couches…no judgement here!).

Networking and entertainment

You read that correctly. We will have live entertainment that'll have you glued to the screen. And you’ll be able to network with SAS experts and peers alike. But you don’t have to wait until the conference begins to network, the SAS Global Forum virtual community is up and running. Join the group to start engaging with other attendees, and maybe take a guess or two at who the live entertainment might be.

A big thank you

We are working hard to bring you the best conference possible, but this isn’t a one-woman show. It takes a team, so I would like to introduce and thank the conference teams for 2021. The Content Advisory Team ensures the Users Program sessions meet the needs of our diverse global audience. The Content Delivery Team ensures that conference presenters and authors have the tools and resources needed to provide high-quality presentations and papers. And, finally, the SAS Advisers help us in a multitude of ways. Thank you all for your time and effort so far!

Registration opens in April, so stay tuned for that announcement. I look forward to “seeing” you all in May.

What makes SAS Global Forum great? was published on SAS Users.

12月 172020
 

There’s nothing worse than being in the middle of a task and getting stuck. Being able to find quick tips and tricks to help you solve the task at hand, or simply entertain your curiosity, is key to maintaining your efficiency and building everyday skills. But how do you get quick information that’s ALSO engaging? By adding some personality to traditionally routine tutorials, you can learn and may even have fun at the same time. Cue the SAS Users YouTube channel.

With more than 50 videos that show personality published to-date and over 10,000 hours watched, there’s no shortage of learning going on. Our team of experts love to share their knowledge and passion (with personal flavor!) to give you solutions to those everyday tasks.

What better way to round out the year than provide a roundup of our most popular videos from 2020? Check out these crowd favorites:

Most viewed

  1. How to convert character to numeric in SAS
  2. How to import data from Excel to SAS
  3. How to export SAS data to Excel

Most hours watched

  1. How to import data from Excel to SAS
  2. How to convert character to numeric in SAS
  3. Simple Linear Regression in SAS
  4. How to export SAS data to Excel
  5. How to Create Macro Variables and Use Macro Functions
  6. The SAS Exam Experience | See a Performance-Based Question in Action
  7. How it Import CSV files into SAS
  8. SAS Certification Exam: 4 tips for success
  9. SAS Date Functions FAQs
  10. Merging Data Sets in SAS Using SQL

Latest hits

  1. Combining Data in SAS: DATA Step vs SQL
  2. How to Concatenate Values in SAS
  3. How to Market to Customers Based on Online Behavior
  4. How to Plan an Optimal Tour of London Using Network Optimization
  5. Multiple Linear Regression in SAS
  6. How to Build Customized Object Detection Models

Looking forward to 2021

We’ve got you covered! SAS will continue to publish videos throughout 2021. Subscribe now to the SAS Users YouTube channel, so you can be notified when we’re publishing new videos. Be on the lookout for some of the following topics:

  • Transforming variables in SAS
  • Tips for working with SAS Technical Support
  • How to use Git with SAS

2020 roundup: SAS Users YouTube channel how to tutorials was published on SAS Users.