9月 102019
 

I recently had the incredible opportunity to attend SAS Global Forum in Dallas as a presenter and New SAS Professional Award recipient. At the conference, I was able to learn more about SAS features and applications, share my knowledge of SAS applications in the clinical trials space, and make new professional connections.

Here are 11 reasons why you should consider applying for this award, too.

1) Free registration & conference hotel: The obvious perk for award winners is the waived fees associated with the cost of attending the conference, including the registration fee, pre-conference tutorial, and free stay at the conference hotel for award winners who are also presenters. As a junior-level employee, it can be difficult to convince your department to allow you to travel to a conference, but it makes it a lot easier to pitch the idea when an award covers most of the costs.

2) See a new city: I arrived at the conference a day early, so I was able to take advantage of my time in Dallas to see the city. I walked around downtown, toured the Dallas Arboretum and Botanical Garden, and ate some delicious barbeque. SAS Global Forum 2020 will be held in Washington D.C., so there will be plenty of sights to see there as well.

3) Receive guidance from a mentor: Award recipients who publish and present a paper are eligible to be matched with a mentor through the Presenter Mentoring Program. My mentor, Chris Battiston, was incredibly friendly, helpful, and personable. He provided advice on presentations to attend, public speaking tips, and even referred me for an opportunity to fly out to Canada as an invited speaker at the SAS Canada Health Users group conference. Having a mentor helped set my expectations for the conference and make a plan to maximize my experience.

4) Open doors to additional opportunities: This award, and my associated presentations, provided me with a huge boost in my credibility and the publicity around my work. As a direct result of presenting at this conference and receiving the award, I received invitations to speak on the main stage in front of 5,000+ people at SAS Global Forum 2019, to attend the SAS Canada Health Users Group as an invited speaker, to serve as a panel speaker at the Research Triangle SAS Users Group, and attend SAS Global Forum 2020 as an invited speaker. I also had opportunities to meet Jim Goodnight and other SAS executives, which was an incredible honor.

5) Speak with SAS employees: Have a question about a SAS procedure? At SAS Global Forum, you can ask your question to the actual developers of those procedures in The Quad. The Quad is a large exhibit and demo area with dozens of SAS booths as well as the conference sponsors. At the booths, I spoke to quite a few representatives from SAS and learned about the variety of areas where SAS is making an impact. I learned about the features and functions of SAS Viya, efforts at SAS to make data visualization accessible to those who are visually impaired, the rationale behind moving the certification exams to a performance-based format, and the free SAS-supported software platform to teach coding to children at a young age.

6) Free swag: Not the most important reason, but still an awesome bonus! I walked away from the conference with two free t-shirts, a backpack from the Pinnacle Solutions sponsor booth, and many trinkets, pens, and notepads collected from the various booths.

7) Have fun: There were quite a few events at the conference that were a lot of fun! It was easy to meet people because everyone at the event was so friendly. There were happy hour events, lunch networking groups where you could sit with a table of people based on common interests, escape rooms, get-togethers for SAS regional user groups, and a big party for all conference attendees on the last night. It is a great opportunity to spend time with the people you meet at the conference.

8) Practice public speaking skills & teach others: Presenting at the conference is a great opportunity to practice speaking in front of a large group and to teach other professionals about some aspect of SAS. As a "New" SAS professional, it may sound daunting to come up with a topic that would be useful for a more experienced audience, but you'd be surprised at the number of people who attend the conference with no knowledge of many of the base procedures. Additionally, conference attendees find it incredibly valuable to learn about how SAS can be used to solve a problem or how an existing common task can be programmed more efficiently. My topic was "Using PROC SQL to Generate Shift Tables More Efficiently", and it taught programmers and statisticians a shorter way to produce shift tables, which are commonly used to present categorical longitudinal data. Because of the preparation I put in to present at the conference, I left the event as a much more confident speaker than I had ever been before.

9) Learn something new: At the conference, you'll have the opportunity to attend sessions on virtually any topic you can think of that is related to SAS. Most of the talks I attended were related to statistics because the topic aligns with my job description as a Biostatistician. Some of the topics I learned about were Bayesian analysis, missing data, survival analysis, clinical graphs, and artificial intelligence. Additionally, the conference allows you opportunities to ask specific questions about any SAS procedure or task you’re struggling with. A resource available at the conference is the “Code Doctors” table in The Quad, where you can ask programming questions to SAS experts. I had the opportunity to serve as a “Resident” for the Code Doctors program and was able to observe and help those who needed advice.


10) Increase visibility within your company:
I was the only attendee from my company out of those working in my office, but there were several senior-level IQVIA employees from other regions in attendance, and I had the opportunity to meet them and spend time with them at the conference. I work at a very large company and would not have had the opportunity to meet these coworkers otherwise, so it was an excellent opportunity to increase my visibility even within my company. Additionally, I’ve had opportunities to apply the knowledge I gained from the conference at work and to share advice with coworkers based on what I learned.

11) Make new connections: Perhaps the most important reason to attend SAS Global Forum as a New SAS Professional is the connections you make at the conference. There are opportunities to meet people from all stages in their career who use SAS to complete statistical analysis. Despite working in different industries, I found that many conference attendees used the same procedures and dealt with the same issues that I did, and I truly felt a sense of community among the long-time attendees. Like most of the programmers, analysts, and statisticians in attendance, my day-to-day work is in a solitary environment on the computer. Although teamwork is involved within project teams, there is not a great amount of face-to-face interactions. I love connecting with other people, and this conference gave me the opportunity to meet other people working in similar positions.

The New SAS Professional Award is perfect for those with the potential to become a leader in their field and who are looking for more opportunities to present their ideas, to network and make connections, and to learn from experts.

This experience has allowed me to expand my skills and network, and served as a launchpad for my successful career. My attendance at the conference has allowed me to feel a greater sense of community with other SAS users, and to serve as a representative from the "next generation" of SAS Professionals. I encourage you to submit your abstract by September 30th and your award application by November 1st if this seems like the right opportunity for you. More details about this award and other award and scholarship opportunities are available on the SAS Global Forum 2020 website.

11 Reasons to Apply for the New SAS Professional Award was published on SAS Users.

9月 102019
 

SASPy is a powerful Python library that interfaces with SAS and can help with your machine-learning solutions. SASPy was created for Python programmers to leverage the power of SAS within their Python scripts. If you are not familiar with SASPy, see the following resources:

This blog post shows you how powerful SASPy can be. SASPy helps you with providing visuals and descriptive statistics quickly and accurately. To demonstrate this capability, let’s explore and prepare your data using SASPy.

Prerequisites

To get started, here is what you need:

  • The Census Income data set from the University of California Irvine’s Machine Learning Repository
    • Download the adult.data data set from the data folder.
    • Remove the missing values prior to exploring and preparing.
  • SAS®9.4 or SAS® Viya® 3.1 or any later variations of these
  • Jupyter Notebook
  • SASPy (To install SASPy, refer to the installation and configuration documentation.)

After verifying you have completed the above requirements, you can start your Jupyter Notebook and begin coding using SASPy.

Let's start by importing libraries we will use in this example

  1. Import the libraries:
  2. Start your SAS session. Use the command below to establish a connection.

A "SAS Connection established" message returns once connected. This example uses a local connection to SAS. However, you can use an STDIO connection or an IOM connection to SAS if you prefer. For more information, see SAS Configuration.

  1. Read in your data set. You have two options: You can either read in the data set using pandas and then read the data into a SAS data object or you can read it directly into a SAS data object. This example shows reading the data directly into a SAS data object.

To access existing data in a SAS session, use the SAS data object. A SAS data object can be used to do the following:

  • Create various graphs such as histograms, scatter plots, heatmaps, and so on.
  • Display descriptive statistics.
  • Transfer data in between a pandas data frame and a SAS data object.

The SAS data object is versatile. To view all of its capabilities, refer to the SAS Data Object documentation.

  1. Verify whether you successfully read in your data set:

Similar to pandas, SASPy has a head function to display data points. The only difference is when you are specifying how many data points you would like to see. You need to include “obs=n” if you are using a SAS data object.

Exploring your Data

SASPy provides many options to explore your data. This example uses a combination of SASPy functions and pandas to explore the data.

  1. Determine the number of records in your data:
  2. Determine how many individuals earn more or less than $50,000. For this step, this example uses pandas to demonstrate how you can switch between using SASPy and pandas seamlessly.
    1. Change your SAS data object into a pandas data frame:
    2. Use the value_counts function to determine how many individuals earn more or less than $50,000:
    3. View the percent of individuals whose income is greater than $50,000:                                               
    4. Display all your values to gain an understanding of your data:

As you can see from the output above, there are 30,162 records. About 7,508 individuals earn more than $50,000, and about 22,654 individuals make up to $50,000. From all the data, you can see about 25% percent of individuals earn more than $50,000.

  1. It is also important to look at your numerical features. Use SASPy to get a quick description of your data:

As you can see above, the table lists calculated values for the mean, median, and other valuable statistical values.

Exploring your data is just the first step in generating your machine-learning solutions. This blog post described how to generate basic statistical values and display output using SASPy, pandas, and Python. Part 2 and 3 of this blog post cover how to prepare your data using SASPy and to then apply it to a machine learning model.

For more information about the data set, see the UC Irvine Machine Learning Repository.

Machine learning with SASPy: Exploring and preparing your data (part 1) was published on SAS Users.

9月 102019
 

SASPy is a powerful Python library that interfaces with SAS and can help with your machine-learning solutions. SASPy was created for Python programmers to leverage the power of SAS within their Python scripts. If you are not familiar with SASPy, see the following resources:

This blog post shows you how powerful SASPy can be. SASPy helps you with providing visuals and descriptive statistics quickly and accurately. To demonstrate this capability, let’s explore and prepare your data using SASPy.

Prerequisites

To get started, here is what you need:

  • The Census Income data set from the University of California Irvine’s Machine Learning Repository
    • Download the adult.data data set from the data folder.
    • Remove the missing values prior to exploring and preparing.
  • SAS®9.4 or SAS® Viya® 3.1 or any later variations of these
  • Jupyter Notebook
  • SASPy (To install SASPy, refer to the installation and configuration documentation.)

After verifying you have completed the above requirements, you can start your Jupyter Notebook and begin coding using SASPy.

Let's start by importing libraries we will use in this example

  1. Import the libraries:
  2. Start your SAS session. Use the command below to establish a connection.

A "SAS Connection established" message returns once connected. This example uses a local connection to SAS. However, you can use an STDIO connection or an IOM connection to SAS if you prefer. For more information, see SAS Configuration.

  1. Read in your data set. You have two options: You can either read in the data set using pandas and then read the data into a SAS data object or you can read it directly into a SAS data object. This example shows reading the data directly into a SAS data object.

To access existing data in a SAS session, use the SAS data object. A SAS data object can be used to do the following:

  • Create various graphs such as histograms, scatter plots, heatmaps, and so on.
  • Display descriptive statistics.
  • Transfer data in between a pandas data frame and a SAS data object.

The SAS data object is versatile. To view all of its capabilities, refer to the SAS Data Object documentation.

  1. Verify whether you successfully read in your data set:

Similar to pandas, SASPy has a head function to display data points. The only difference is when you are specifying how many data points you would like to see. You need to include “obs=n” if you are using a SAS data object.

Exploring your Data

SASPy provides many options to explore your data. This example uses a combination of SASPy functions and pandas to explore the data.

  1. Determine the number of records in your data:
  2. Determine how many individuals earn more or less than $50,000. For this step, this example uses pandas to demonstrate how you can switch between using SASPy and pandas seamlessly.
    1. Change your SAS data object into a pandas data frame:
    2. Use the value_counts function to determine how many individuals earn more or less than $50,000:
    3. View the percent of individuals whose income is greater than $50,000:                                               
    4. Display all your values to gain an understanding of your data:

As you can see from the output above, there are 30,162 records. About 7,508 individuals earn more than $50,000, and about 22,654 individuals make up to $50,000. From all the data, you can see about 25% percent of individuals earn more than $50,000.

  1. It is also important to look at your numerical features. Use SASPy to get a quick description of your data:

As you can see above, the table lists calculated values for the mean, median, and other valuable statistical values.

Exploring your data is just the first step in generating your machine-learning solutions. This blog post described how to generate basic statistical values and display output using SASPy, pandas, and Python. Part 2 and 3 of this blog post cover how to prepare your data using SASPy and to then apply it to a machine learning model.

For more information about the data set, see the UC Irvine Machine Learning Repository.

Machine learning with SASPy: Exploring and preparing your data (part 1) was published on SAS Users.

9月 092019
 

If you consume NBA content through social media, then you know just how active that online community is. Basketball arguments and ‘hot takes’ on the Internet are about as commonplace as Michael Jordan playing golf instead of running a functional NBA front office. I wondered if NBA fans happened to [...]

The Memphis Grizzlies have the best NBA arena. Here's why was published on SAS Voices by Frank Silva

9月 092019
 

If you consume NBA content through social media, then you know just how active that online community is. Basketball arguments and ‘hot takes’ on the Internet are about as commonplace as Michael Jordan playing golf instead of running a functional NBA front office. I wondered if NBA fans happened to [...]

The Memphis Grizzlies have the best NBA arena. Here's why was published on SAS Voices by Frank Silva

9月 092019
 

Editor's Note: This article was translated and edited by SAS USA and was originally written by Makoto Unemi. The original text is here.

SAS previously provided SAS Scripting Wrapper for Analytics Transfer (SWAT), a package for using SAS Viya functions from various general-purpose programming languages ​​such as Python.

In addition to SWAT, SAS launched Deep Learning Python (DLPy), a higher-level API package for Python, making it possible to use SAS Viya functions more efficiently from Python. In this article I outline more about what DLPy is and how it's implementation.

About DLPy

DLPy is a high-level package for the Python API created for deep learning and image action set after Viya3.3. DLPy provides an API similar to Keras to improve the efficiency of deep learning and image processing coding. With just a little rewriting of the existing Keras code, it is possible to execute the processing on SAS Viya.

For example, below is an example of a Convolutional Neural Network (CNN) layer definition; you can see that it is very similar to Keras.

The layers supported by DLPy are: InputLayer, Conv2d, Pooling, Dense, Recurrent, BN, Res, Proj, and OutputLayer. The following is an example of learning.

DLPy functions

Introducing DLPy's functions (partial excerpts), taking as an example the learning of multiple dolphins and giraffe images using CNN and applying test images to the model.

Implementation of major deep learning networks

DLPy offers the following pre-built deep learning models: VGG11/13/16/19, ResNet34/50/101/152, wide_resnet, and dense_net.

The following models also offer pre-trained weights using ImageNet data (these weights can be used for unique tasks by transfer learning): VGG16, VGG19, ResNet50, ResNet101, and ResNet152. The following is an example of transferring ResNet50 pre-trained weights.

CNN judgment basis information

Using the heat_map_analysis() method, you can output a colorful heat map and check where you focused on the image.

In addition, the get_feature_maps() method is used to get the feature map of each layer of CNN, and feature_maps.display() method is used to specify and display the obtained feature map layer and check can also do.

The following is the output result of layer 1 feature map.

The following is the output result of layer 18 feature map.

Deep learning & image processing related task support function

resize() method: Resize image data

as_patches() method: Image data expansion (generates a patch from the original image)

two_way_split() method: Data split (learning, testing)

plot_network() method: draws the structure of the defined deep learning layer (network) as a graphical diagram

plot_training_history() method: Iterative learning history display

predict() method: Display prediction (scoring) results

plot_predict_res() method: Display classification results

And of course, you can use DLPy to get data from a SAS Viya in-memory session, pass it to your local client, and convert it to common data formats like numpy arrays and Pandas DataFrames. The converted data can be smoothly supplied to models of other open source packages such as scikit-learn.

Regarding image classification using DLPy, videos are also available in the Deep Learning with Python (DLPy) Demo Series section of the DLPy product page.

SAS Viya: Package for Python API for deep learning and image processing: DLPy was published on SAS Users.

9月 092019
 

The TEXT statement in PROC SGPLOT supports the ROTATE= option to rotate the specified text. It is worth knowing how the ROTATE= option interacts with the POSITION= option, which determines the anchor point at which the text is positioned. Briefly, the text is positioned FIRST, then the rotation occurs. The following list summarizes the interaction for common choices of the POSITION= option:

  • POSITION=LEFT: The text is positioned to the left of the anchor point, then rotated around the anchor point. For example, if you rotate by 90 degrees, the text will be below the anchor point.
  • POSITION=RIGHT: The text is positioned to the right of the anchor point, then rotated around the anchor point. For example, if you rotate by 90 degrees, the text will be above the anchor point.
  • POSITION=BOTTOM: The text is positioned below the anchor point, then rotated around the anchor point. For example, if you rotate by 90 degrees, the text will be to the right of the anchor point.
  • POSITION=TOP: The text is positioned above the anchor point, then rotated around the anchor point. For example, if you rotate by 90 degrees, the text will be to the left of the anchor point.

This summary is best illustrated by showing examples of rotated text. In the following example, the anchor point is always (0,0). The program uses either POSITION=LEFT or POSITION=RIGHT to positions a text string, which is then rotated through a series of angles.

data TextRotate;
retain x y 0;
length Labl $ 30;
do Angle = 0 to 315 by 45;
   Labl = catx(' ', '---', 'Angle', Angle, '---');
output;
end;
 
ods graphics / width=300px height=300px;
%macro RotateTextPlot(position);
title "Rotated Text - POSITION=&position";
proc sgplot data=TextRotate noautolegend;
   scatter x=x y=y / markerattrs=(symbol=CircleFilled);
   text x=x y=y text=labl / rotate=Angle position=&position textattrs=(size=12);
   yaxis display=none;
run;
%mend;
 
%RotateTextPlot(LEFT);
%RotateTextPlot(RIGHT);

In a similar way, the following DATA step creates a series of anchor points on the unit circle. The program uses either POSITION=BOTTOM or POSITION=TOP to positions a text string, which is then rotated by an angle.

data TextRotate;
length Labl $ 30;
pi = constant('pi');
do Angle = 0 to 315 by 45;
   x = cos(Angle*pi/180); y = sin(Angle*pi/180);
   Labl = catx(' ', '---', 'Angle', Angle, '---');
output;
end;
 
%RotateTextPlot(BOTTOM);
%RotateTextPlot(TOP);

Be aware that this behavior is different from the way that text rotation works in SG annotation. To see how the anchor point (the value of the ANCHOR variable) interacts with the rotation angle (the ROTATE variable) in an SG annotation, see pp. 113–116 in Warren Kuhfeld's free e-book, Advanced ODS Graphics Examples, which inspired the graphs in this blog post. Briefly, if you anchor text on the left, then the text is positioned to the right, and vice versa.

The post Anchor points and rotated text in PROC SGPLOT appeared first on The DO Loop.

9月 082019
 


Today, September 8th, is International Literacy Day! A day celebrated by UNESCO since 1967 to emphasize the importance of literacy around the world. Here at SAS, we have decided to highlight data literacy, a critical part of our evolving knowledge as data and analytics continue to dominate the way we do business.

SAS Press author Susan Slaughter defines data literacy as, “understanding that data are not dry, dusty, abstract squiggles on a computer screen, but represent living things: people, plants, animals. You know you are fluent in a foreign language when you are comfortable speaking it and can communicate what you want to say. The same is true for data literacy; it is about reaching a level of comfort, about being able to communicate what is important to you, and about seeing the meaning behind the data.

Everyone knows that technology is becoming more and more a part of everyday life. Without data literacy, people become passive recipients; with data literacy, you can actively engage with technology. SAS calls it ‘the power to know’ and that's an accurate description.”

SAS Press has been helping users be more fluent in data literacy for almost 30 years! The Little SAS Book is about to publish its sixth edition and has been helping programmers learn SAS and analyze their data since 1995.

Free SAS Press e-books

To celebrate national literacy day and do our part in sharing about data literacy, SAS Press would like to share with you our free e-books on a range of topics related to data analytics. These books focus on topics such as text analytics, data management, AI, and Machine Learning.

Moving to the cloud?

Looking for information on SAS Viya? Download our two new free e-books on Exploring SAS Viya. Both books cover the features and capabilities of SAS Viya. SAS Viya extends the SAS platform to enable everyone – data scientists, business analysts, developers, and executives alike – to collaborate and realize innovative results faster.

Here is a list of our free e-books on SAS Viya:

Exploring SAS ®Viya®: Programming and Data Management
This first book in the series covers how to access data files, libraries, and existing code in SAS® Studio. You also will learn about new procedures in SAS Viya, how to write new code, and how to use some of the pre-installed tasks that come with SAS® Visual Data Mining and Machine Learning.

Exploring SAS® Viya®: Visual Analytics, Statistics, and Investigations
Data visualization enables decision-makers to see analytics presented visually so that they can grasp difficult concepts or identify new patterns. This book includes four visualization solutions powered by SAS Viya: SAS Visual Analytics, SAS Visual Statistics, SAS Visual Text Analytics, and SAS Visual Investigator.

Interested in learning more?

As becoming more data literate becomes increasingly more important in our daily lives, knowing where to get new information and tools to learn becomes critical to innovation and change. To stay up-to-date on new SAS Press books and our new free e-books releases, subscribe to our monthly newsletter.

Celebrating #InternationalLiteracyDay with Free SAS E-books! was published on SAS Users.

9月 072019
 

By 2020, 50% of organizations will lack sufficient AI and data literacy skills to achieve business value. – Gartner

What is data literacy?

Data literacy is the ability to read, work with, analyze, and argue with data. – Wikipedia

Data literacy is the ability to derive meaningful information from data, just as literacy in general is the ability to derive information from the written word. – WhatIs.com

Why is it important?

As data and analytics become core to the enterprise, and data becomes an organizational asset, employees must have at least a basic ability to communicate and understand conversations about data. Just as it is a given that employees are now competent in word processing and spreadsheets, the ability to “speak data” will become an integral aspect of most day-to-day jobs.

Gone will be the days when data scientists, analysts, and statisticians are the only ones “speaking data.” Valerie Logan, Senior Director Analyst, Gartner, says workforce data literacy must treat information as a second language. Just as we expect all employees today to have a basic level of computer literacy, use email, and understand spreadsheets, employees will also need to be able to understand and speak basic data.

Chris Hemedinger, author of SAS for Dummies, touched on this in his blog a skeptics guide to statistics in the media. He is old enough to remember when USA Today began publication in the early 1980s. He remembers scanning each edition for the USA Today Snapshots, a mini infographic feature that presented some statistics in a fun and interesting way. “Back then, I felt that these stats made me a little bit smarter for the day. I had no reason to question the numbers I saw, nor did I have the tools, skill, or data access to check their work.”

Chris warns that as more and more “news articles and editorial pieces often use simplified statistics to convey a message or support an argument,” we will need to learn that “statistics in the media should not be accepted at face value.” Learning to analyze and understand data and statistics will become increasingly more vital for future generations.

Best-selling SAS Press author, Ron Cody, cautions that with the augmented technology that allows non-programmers to be able to run complex programs to search databases, summarize data, and conduct statistical tests, it is vital that everyone has a basic understanding of the data and analytics behind the results. “With advances in artificial intelligence, we may be able to tell the computer our problem and let it solve it and tell us the answer.” With technology advancing so quickly with AI, we will all need to understand the data and avoid including bias into our models. Misunderstood data can negatively influence AI algorithms or interpretation of models.

The future

Tom Fisher, Senior Vice President of Business Development at SAS explains, “the convergence of model management with data management represents one of the most exciting business opportunities of the future. The merging and blending of these two disciplines should enable the elimination of bias that may occur in the collection and aggregation of data.” Initiatives such as MIT’s Data Nutrition Project address the missing step in the model development pipeline, “assessing data sets based on standard quality measures that are both qualitative and quantitative.” As Fisher concludes, “these kinds of approaches are designed to allow consumers of data, as input to models, to have a more complete understanding of the data that’s being ingested. At the end of the day, the goal of these integrated disciplines is to provide greater accuracy and comfort with the result sets that are being delivered by data scientists and data engineers.”

As the Gartner report quoted earlier notes, as organizations become more data-driven, poor data literacy will become an inhibitor to growth. But not everyone wants to be a statistician or data scientist. This is where the analogy to computer literacy parts ways. We don’t all have to have a statistics degree – AI can help. SAS is developing solutions where AI is augmented into its most sophisticated and powerful solutions to give everyone data literacy. For example, SAS® Model Manager looks at the data and the problem to suggest models. It can then choose the best model based on the user’s criteria, test the model, and score. Technology to report and explain the results, and even answer questions is under development – all in natural language! A virtual personal assistant who can “speak data” and translate.

While data literacy will become increasingly important, so too will tools to help moderate and translate the data that will continue to drive our enterprises and our lives.

Resources:
Become more data literate with our library of Getting Started with SAS, Statistics, Machine Learning, and Data Management books. Visit SAS Books.

Explore SAS Analytics Industry Solutions at sas.com/industry.

Why we need to learn how to "speak data" in a data-driven future was published on SAS Users.

9月 062019
 

A few years ago I shared a method to publish content from SAS to a Slack channel. Since that time, our teams at SAS have gone "all in" on collaboration with Microsoft Office 365, including Microsoft Teams. Microsoft Teams is the Office suite's answer to Slack, and it's not a coincidence that it works in nearly the same way.

The lazy method: send e-mail to the channel

Before I cover the "deluxe" method for sending content to a Microsoft Teams channel, I want to make sure you know that there is a simple method that involves no coding, and no need for APIs. The message experience isn't as nice, but it does the job. You can simply "send e-mail" to the channel. If you're automating output from SAS, it's a simple, well-documented process to send e-mail from a SAS program. (Here's an example from me, using FILENAME EMAIL.)

When you send e-mail to a Microsoft Teams channel, the message notice includes the message subject line, sender, and the first bit of the message content. To see the entire message, you must click on the "View original e-mail" link in the notice. This "downloads" the message to your device so that you can open it with a local tool (such as your e-mail reader, Microsoft Outlook). My team uses this method to receive certain alerts from our communities.sas.com platform. Here's an example:

To get the unique e-mail address for a channel, right-click on the channel name and select Get email address. Any message that you send to that e-mail address will be distributed to the team.

Getting started with a Microsoft Teams webhook

In order to provide a richer, more integrated experience with Microsoft Teams, you can publish content using a webhook. A webhook is a REST API endpoint that allows you to post messages and notifications with more control over the appearance and interactive options within the messages. In SAS, you can publish to a webhook by using PROC HTTP.

To get started, you need to add and configure a webhook for your Microsoft Teams channel:

  1. Right-click on the channel name and select Connectors.
  2. Microsoft Teams offers built-in connectors for many different applications. To find the connector for Incoming Webhook, use the search field to narrow the list. Then click Add to add the connector to the channel.
  3. You must grant certain permissions to the connector to interact with your channel. In this case, you need to allow the webhook to send messages and notifications. Review the permissions and click Install.
  4. On the Configuration page, assign a name to this connector and optionally customize the image. The image will be the avatar that's used when the connector posts content to the channel. When you've completed these changes, select Create.
  5. The connector generates a unique (and very long) URL that serves as the REST API endpoint. You can copy the URL from this field -- you will need it later in your SAS program. You can always come back to these configuration settings to change the connector avatar or re-copy the URL.

    At this point, it's a good idea to test that you can publish a basic message from SAS. The "payload" for a Teams message is a JSON-formatted structure, and you can find examples in the Microsoft Teams reference doc. Here's a SAS program that publishes the simplest message. Add your webhook URL and run the code to verify the connector is working for your channel.

    filename resp temp;
    options noquotelenmax;
    proc http
      /* Substitute your webhook URL here */
      url="https://outlook.office.com/webhook/your-unique-webhook-address-it-is-very-long"
      method="POST"
      in=
      '{
          "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
          "type": "AdaptiveCard",
          "version": "1.0",
          "summary": "Test message from SAS",
          "text": "This message was sent by **SAS**!"
      }'
      out=resp;
    run;

    If successful, this step will post a simple message to your Teams channel:

    Design a message card for Microsoft Teams

    Now that we have the basic plumbing working, it's time to add some bells and whistles. Microsoft Teams calls these notifications "message cards", which are messages that can include interactive features such as images, data, action buttons, and more.

    Designing a simple message

    Microsoft Teams supports a large palette of building blocks (expressed in JSON) to create different card experiences. You can experiment with these cards in the MessageCard Playground that Microsoft hosts. The tool provides templates for several card varieties, and you can edit the JSON definitions to tweak and design your own.

    For one of my use cases, I designed a simple card to show the status of our recommendation engine on SAS Support Communities. (Read this article for more information about how we built and monitor the recommendation engine.) The engine runs as a service and is accessed with its own API. I wanted a periodic "health check" to post to our internal team that would alert us to any problems. Here's the JSON that I used in the MessageCard Playground to design it.

    Much of the JSON is boilerplate for the message. I drew the green blocks to indicate the areas that need to be dynamic -- that is, replaced with values from the real-time API call. Here's what the card looks like when rendered in the Microsoft Teams channel.

    Since my API call to the recommendation engine service creates a data set, I can run that data through PROC JSON to create the JSON segment I need:

    /* reading the results from my API call to the engine */
    libname results json fileref=resp;
     
    /* Prep a simple name-value data set with the results */
    data segment (keep=name value);
     set results.root;
     name="Score data updated (UTC)";
     value= astore_creation;
     output;
     name="Topics scored";
     value=left(num_topics);
     output;
     name="Number of users";
     value= left(num_users);
     output;
     name="Process time";
     value= process_time;
     output;
    run;
     
    /* use PROC JSON to create the segment */
    filename segment temp;
    proc json out=segment nosastags pretty;
     export segment;
    run;

    I shared a version of the complete program on GitHub. It should run as is -- but you would need to supply your own webhook endpoint for a channel that you can publish to.

    Design a message with actions

    I also use Microsoft Teams to share updates about the SAS Software GitHub organization. In a previous article I discussed how I use GitHub APIs to gather data from the GitHub service. Each day, my program summarizes the recent activity from github.com/sassoftware and publishes a message card to the team. Here's an example of a daily update:

    This card is fancier than my first example. I added action buttons that can direct the team members to the internal reports for more details and to the GitHub site itself. I used the Microsoft Teams documentation and the MessageCard Playground to design the experience:

    Messaging apps as part of a DevOps strategy

    Like many organizations, we (SAS) invest a considerable amount of time and energy into gathering metrics and building reports about our operations. However, reports are useful only when the intended audience is tuned in and refers to them regularly. With a small additional step, you can use SAS to bring your most interesting data forward to your team -- automatically.

    Whether you use Microsoft Teams or Slack, automated alerting and updates are a great opportunity to keep your teams informed. Each of these tools offers fit-for-purpose connectors that can tie in with information from other popular operational systems (Salesforce, GitHub, Yammer, JIRA, and many more). For cases where a built-in connector is not available, the webhook approach allows you to easily create your own.

The post How to publish to a Microsoft Teams channel using SAS appeared first on The SAS Dummy.