5月 202022
 

In the previous article, we demonstrated how to run CMS-HCC Risk Adjustment Models using SAS Analytics Pro on Viya. Recall that we used the SAS Studio interface to access the demographic and diagnoses input data, set up the model score code and score the input data.

In this third article, we will introduce an alternative approach that surfaces the CMS-HCC Risk Adjustment Model execution through SASPy integration to a Flask application. We will demonstrate how this integration allows a user to score an individual patient/member on-demand, using inputs to an interactive web form to execute the model score code, surfacing the resulting score to the user.

You may be thinking, "Why would I want to do this? Isn’t it sufficient to run the CMS-HCC Risk Adjustment Models manually as necessary?" Of course, there is nothing wrong with running the models via SAS Studio as needed and relying on a person to do so.

However, there are scenarios where an automated approach, less dependent on the active participation of a person and integrated with a third-party application is preferred. For example, you may need your CMS-HCC Risk Adjustment Model to run on-demand based on a 3rd party application that was developed by your clients or you may need to run the models as part of a process that is detached from your SAS deployment.

In these cases, you can take advantage of SAS, SASPy integration and cloud infrastructure to achieve the level of automation and integration required. Rather than the MacBook deployment leveraged in the prior article, we will use a deployment of SAS Analytics Pro Viya on a Linux server instance in Azure.

The following lists the step-by-step process to run the CMS-HCC Risk Adjustment Model through SASPy API integration to a Flask application.

  1. The Flask application receives the input form data from the web browser as JSON
  2. Python uses SASPy to connect to SAS Analytics Pro Viya via SSH
  3. SASPy parses the JSON input into SAS tables
  4. SASPy submits SAS code with the SAS tables as input to SAS Analytics Pro on Viya
  5. SAS Analytics Pro Viya runs the code and generates an output SAS table in the output folder
  6. SASPy accesses the output SAS table and converts it to a Pandas data frame
  7. Flask exposes the data frame as JSON back to the web browser

To achieve this integrated process, we are going to walk through all the necessary deployment and configuration steps in a video. To follow along, the following items are required:

  • Azure subscription
  • Azure Linux instance deployed
  • License for SAS Analytics Pro Viya – save it under the sasinside folder
  • Knowledge of Linux to execute scripts
  • Familiarity with Docker containers
  • Clone the provided GitHub repository

Watch the video below to see a detailed demonstration of the deployment and configuration steps.

The video follows the whole process with the high-level steps outlined here.

  1. Deploy an Azure instance with Ubuntu
  2. Install Docker on this instance
  3. Clone the GitHub repository
  4. Install SAS Analytics Pro on Viya container
  5. Configure password-less SSH
  6. Build the Flask application container
  7. Run the Flask application container
  8. Test password-less SSH from the Flask application container to the SAS Analytics Pro on Viya container
  9. Configure ports on the Azure instance to confirm it is accessible from my machine
  10. Run the application on the browser to score a patient/member with the CMS-HCC model

This is the overall architecture of the application found on this GitHub repository.

If you followed along with the deployment and configuration, you may have additional questions. If you are wondering about the purpose of the sascfg_personal.py file, it tells SASPy how to connect via SSH to the SAS Analytics Pro on Viya container. You have to specify the host, localhost and luser options to make sure SASPy can successfully connect.

If you run the SAS Analytics Pro on Viya container first, Docker will probably assign 172.17.0.2 as the IP for that container and 172.17.0.3 for the Flask container. If you suspect the IP is different, inspect the container to make sure the IP is correct.

 
SAS_config_names   = ['ssh']
ssh                = {'saspath'  : '/opt/sas/viya/home/SASFoundation/sas',
                      'ssh'      : '/usr/bin/ssh',
                      'host'     : '172.17.0.2', # sas apro container host
                      'luser'    : 'sasdemo',
                      'localhost': '172.17.0.3', # local Python container ip address
                      'options'  : ["-fullstimer"]
                     }

For more information, check out the official documentation page.

Thanks to everyone that contributed to this blog series and to those that followed it from the beginning. I hope this was helpful and that you learned something along the way.

*If you are interested in a license for SAS Analytics Pro on Viya, contact your SAS representative or get in contact with SAS through the chatbot on sas.com.

Running CMS Risk Adjustment Models via API with SAS Analytics Pro (Viya) on Azure was published on SAS Users.

5月 182022
 

The business case for diversity and inclusion is clear. Research has shown that diverse organizations are more profitable, more innovative and more desirable to employees. So how do we as marketers contribute to making our organizations inclusive? I believe that we must start by cultivating curiosity. Curiosity fuels diversity and inclusion Curiosity [...]

Want to make your marketing team more inclusive? Try this was published on SAS Voices by Jenn Chase

5月 172022
 

Here at SAS, we understand the importance of having access to cutting-edge professional resources. That’s why, for more than 40 years, we’ve provided individuals in programming, data management and analytics fields with low-cost and no-cost materials that promote success in their educational and professional journeys. And today, as the demand for employees with advanced skill sets and global certifications grows, we get it – having the ability to easily access the tools you need to succeed is more important than ever.

We’ve got you covered.

As part of our ongoing commitment to helping individuals enhance their skills, further their careers and increase their chance of success in the field, we’re now offering SAS Certification Practice Exams for free. Yes, free.

Over the years, candidates who have taken advantage of our practice exams have found them to be a valuable, effective tool for gauging their preparedness for SAS Certification Exams. When combined with other SAS training resources – like webinars, content guides, training courses and web tutorials – these free exams greatly increase candidates’ chances of success. Exams are currently available in:

    • Programming
    • Advanced Analytics
    • Data Management
    • Visual Analytics
    • Administration

Representative of the live exams, our online practice exams go through the same rigorous development process and are designed to give candidates an idea of what they should expect in the actual test questions. SAS practice exams also provide the rationale behind correct and incorrect answers, giving participants even more insight and opportunity for exam success.

And the numbers speak for themselves.*

    • Those who passed the practice exam had a 17.5% higher pass rate on the live exam than those who did not take or pass the practice version.
    • Those who took the practice exam – regardless of score – had an 8.15% higher pass rate on the live exam than those who opted not to take it.

Not to mention taking a practice test just might make the difference between passing the SAS Certification Exam on the first try or having to retake it. We’ve found that many who don’t pass the Certification Exam miss the mark by only a few questions, which they could have avoided with a bit more preparation.

Keep in mind, in order to make the best use of this resource, we recommend taking a practice exam as your final method of study in order to test your preparedness before diving into the actual exam. If you are curious about the types of questions typically on the certification exams, we have sample questions available for you to review.

So, what are you waiting for? A free resource to prepare you for a globally-recognized certification and make your resume stand out from the rest? That’s a no-brainer.

For more information about free SAS Certification Practice Exams, visit: https://www.sas.com/en_us/certification/resources/sas-practice-exams.html

*Based on data from 20,000 practice exams taken since 2020.

Access for success: SAS Certification practice exams now offered for free was published on SAS Users.

5月 162022
 

Just getting started with this series? Make sure to explore the earlier posts Part 1, Part 2 and Part 3.

Up until now, you have seen how ModelOps can solve your biggest machine learning challenges and that SAS and Microsoft, together, can help you deploy, govern and monitor your models anywhere in the Microsoft Cloud. But what does that look like in practice and what value does that provide you?

In this blog, we will share how to register SAS and open-source models from SAS Model Manager to Azure Machine Learning and then call that model directly from Power BI.

SAS Model Manager is a centralized, searchable repository for all types of models and analytical assets. This solution gives you complete visibility into your analytical processes, ensuring traceability and governance. SAS Viya on Azure allows you to efficiently move your analytical models from the innovation lab into production. With SAS and Microsoft, you can now easily and seamlessly deploy models in Azure Machine Learning (AML).

Step 1: SAS Model Manager governs, deploys, and monitors all types of SAS and open-source models (i.e., Python, R). Deploy your model registered in SAS Model Manager to Azure Machine Learning.

Once a model is deployed into Azure Machine Learning it can be leveraged just like any other model in Azure Machine Learning while maintaining the governance and control that Viya offers.

Step 2: Refresh Azure Machine Learning to find your model with associated artifacts and variable metrics that can be used to publish the model in an executable container runtime supporting SAS and open-source models.

After you publish a model to an Azure Machine Learning publishing destination you can deploy the published model to AKS. This enables you to make the published model available so that you score it using custom code or another application outside the SAS Viya environment. It also enables you to deploy the published model in a production environment.

Step 3: Go back to SAS Model Manager to deploy the model to AKS (Azure Kubernetes Services) which is the Azure Machine Learning compute target. This steps ensures that the model you have published is ready to be deployed.

Step 4: Score your model in Azure Machine Learning.

Step 5: Score your model from Power BI.

When a new model is developed and ready for production, it is easy to register that model in Azure Machine Learning and replace the existing model that is in production. This allows business intelligence users to quickly gain access to the most accurate insights. By leveraging the strengths of the ModelOps lifecycle that SAS has developed the deployment mechanism and distribution of that model using the Microsoft Cloud, models can be pushed out into production in an automated and repeatable way. The combination of SAS Viya and Azure Machine Learning accelerates the time to value for customers who are looking to incorporate DevOps principles into their model development and deployment.

To learn more about ModelOps and our partnership with Microsoft, see our whitepaper: ModelOps with SAS Viya on Azure.

ModelOps in practice: How to call SAS models from Microsoft Power BI, part 4 was published on SAS Users.

5月 162022
 

In categorical data analysis, it is common to analyze tables of counts. For example, a researcher might gather data for 18 boys and 12 girls who apply for a summer enrichment program. The researcher might be interested in whether the proportion of boys that are admitted is different from the proportion of girls. For this analysis, the data that you type into statistical software (such as SAS) does not typically consist of 20 observations. Rather, the data often consists of four observations and a frequency variable (also call a count variable). The first two observations record the number of boys that are admitted and not admitted, respectively. The next two observations record the corresponding frequencies for the girls.

This representation of the data is sometimes called frequency data. It is used when you can group individual subjects into categories such as boy/girl and admitted/not admitted. Despite its convenience, there are times when it is useful to expand or "unroll" the data to enumerate the individual subjects. Examples include bootstrap estimates and analyzing the data in SAS procedures that do not support a FREQ statement.

This article shows how to use the SAS DATA step to unroll frequency data. In addition, this article shows how to expand data that are in events/trials format.

Data in frequency form

The following example is from the documentation of the FREQ procedure. The goal is to compute some statistics for a 2 x 2 frequency table for 23 patients. Eight patients were on a low-cholesterol diet and 15 were on a high-cholesterol diet. The table shows how many subjects in each group developed heart disease. The data are used to estimate the relative risk of developing heart disease in the two groups:

/* Doc Example: PROC FREQ analysis of a 2x2 Contingency Table */
proc format;
   value ExpFmt 1='High Cholesterol Diet'  0='Low Cholesterol Diet';
   value RspFmt 1='Yes'  0='No';
run;
 
data FatComp;
format Exposure ExpFmt. Response RspFmt.;
input Exposure Response Count;
label Response='Heart Disease';
datalines;
0 0  6
0 1  2
1 0  4
1 1 11
;
 
title 'Case-Control Study of High Fat/Cholesterol Diet';
proc freq data=FatComp;
   tables Exposure*Response / relrisk norow nocol nopercent;
   weight Count;            /* each row represents COUNT patients */
run;

Notice that the data are input in terms of group frequencies. The output is shown. The analysis estimates the risk of heart disease for a subject on a high-cholesterol diet as 2.8 times greater than the risk for a subject on a low-cholesterol diet.

How to unroll frequency data in SAS

You can use the DATA step in SAS to unroll the frequency data. The COUNT variable tells you how many patients are in each group. You can therefore write a loop that expands the data: iterate from 1 to the COUNT value and put an OUTPUT statement in the body of the loop. If desired, you can include an ID variable to enumerate the subjects in each group, as follows:

data RawFat;
set FatComp;
Group + 1;          /* identify each category */
do ID = 1 to Count; /* identify subjects in each category */
   output;
end;
drop Count;
run;
 
proc print data=RawFat(obs=10);
run;

Whereas the original data set has four rows, the RawFat data has 23 rows. The first 10 rows are shown. The first six observations are the expansion of the subjects in the first group (Exposure=Low; Response=No). The next two observations are the subjects in the second group (Exposure=Low; Response=Yes), and so forth. The GROUP variable identifies the original groups. The ID variable enumerates patients within each group.

The second data set can be analyzed by any SAS procedure. In this form, the data do not require using a FREQ statement (or the WEIGHT statement in PROC FREQ), as shown by the following call to PROC FREQ:

/* run the same analysis on the expanded data */
proc freq data=RawFat;
   tables Exposure*Response / relrisk norow nocol nopercent;
   /* no WEIGHT statement because there is one row for each patient */
run;

The output (not shown) is the same as for the frequency data. Both data sets contain the same information, but the second might be useful for certain tasks such as a bootstrap analysis.

Data in events/trials form

A related data format is called the events/trials format. In the events/trials format, each observation has two columns that specify counts. One column specifies the number of times that a certain event occurs, and the other column specifies the number of trials (or attempts) that were conducted. This format is used for logistic regression and for other generalized linear regression models that predict the proportion of events.

The following example is from the documentation for the LOGISTIC procedure. The data describe the result of 19 batches of ingots in a designed experiment. Each batch was soaked and heated for specified combinations of times. The ingots were then inspected to determine which were not ready for rolling. The following DATA step records the results in the events/trials syntax. The R variable records the number of ingots that are not ready for rolling, and the N variable contains the number of ingots in the batch at the given values of the HEAT and SOAK variables. Consequently, R/N is the proportion of ingots that were not ready. For example, the values R=4 and N=44 means that 4 ingots (9%) were not ready for rolling in a batch that contained 44. Regression procedures such as PROC LOGISTIC enable you to analyze data by using an events/trials syntax:

/* events/trials syntax */
data ingots;
   input Heat Soak r n @@;
   datalines;
7 1.0 0 10  14 1.0 0 31  27 1.0 1 56  51 1.0 3 13
7 1.7 0 17  14 1.7 0 43  27 1.7 4 44  51 1.7 0  1
7 2.2 0  7  14 2.2 2 33  27 2.2 0 21  51 2.2 0  1
7 2.8 0 12  14 2.8 0 31  27 2.8 1 22  51 4.0 0  1
7 4.0 0  9  14 4.0 0 19  27 4.0 1 16
;
 
proc logistic data=ingots;
   model r/n = Heat Soak;
   ods select NObs ResponseProfile ParameterEstimates;
run;

The "NObs" table shows that there are 19 rows of data, which represents 387 units. The "Response Profile" table counts and displays the number of events and the number of trials. For these data, 12 units were not ready for rolling. The "ParameterEstimates" table provides estimates for the Intercept and the coefficients of the effects in the logistic regression model.

How to expand event/trials data

You can expand these data by creating 387 observations, one for each unit. The following DATA step creates a variable named BATCH that enumerates the original 19 batches of ingots. The ID variable enumerates the units in each batch. Some of the units were ready for rolling and some were not. You can create an indicator variable (NOTREADY) that arbitrarily sets the first R ingots as "not ready" (NOTREADY=1) and the remaining ingots as ready (NOTREADY=0).

/* expand or unroll the events/trials data */
data RawIngots;
set ingots;
BatchID + 1;
do ID = 1 to n;
   NotReady = (ID <= r);
   output;
end;
run;
 
/* analyze the binary variable NOTREADY */
proc logistic data=RawIngots;
   model NotReady(event='1') = Heat Soak;
   ods select NObs ResponseProfile ParameterEstimates;
run;

The "NOBs" and "Response Profile" tables are different from before, but they contain the same information. The "ParameterEstimates" table is the same and is not shown.

Summary

In categorical data analysis, it is common to analyze data that are in frequency form. Each observation represents some number of subjects, and the number is given by the value of a Count variable. In some situations, it is useful to "unroll" or expand the data. If an observation has frequency C, it results in C observations in the expanded data set. This article shows how to use the SAS DATA step to expand frequency data and data that are in events/trials syntax.

The post How to unroll frequency data appeared first on The DO Loop.

5月 132022
 

As more businesses embrace their digital transformation journeys, it’s easy to get lost in the cloud hype and overinflate the possibilities of cloud alone. Cloud migration is not a one-stop shop to solve all of an organization’s challenges. Instead, technology leaders need to adopt a cloud-smart mindset to maximize value, [...]

The transformative impact of SAS Viya on Azure was published on SAS Voices by Jay Upchurch

5月 122022
 

Broadband has become widely available and 5G is up and running in many countries, meaning more and more people have access to the internet via different platforms. With good quality internet connections either at home or via mobile connections, consumer behaviour has changed rapidly. Those who have been in digital [...]

Analyzing the data of an evolving video streaming service ecosystem was published on SAS Voices by Cornelia Reitinger

5月 122022
 

Broadband has become widely available and 5G is up and running in many countries, meaning more and more people have access to the internet via different platforms. With good quality internet connections either at home or via mobile connections, consumer behaviour has changed rapidly. Those who have been in digital [...]

Analyzing the data of an evolving video streaming service ecosystem was published on SAS Voices by Cornelia Reitinger

5月 112022
 

Students at North Carolina State University completed design projects yielding striking visuals, purpose and functionality without unethical design characteristics. If you were to design the ultimate vacation home, you would most certainly consider options and features that speak to your individual preferences and style. It turns out that same inclination [...]

Exploring innovative modeling designs built to battle bias was published on SAS Voices by Becky Graebe

5月 102022
 

A cancer journey affects both physical and mental health. This often results in feelings of social isolation, loss of identity, clinical depression and even PTSD. This often goes unrecognized and undiagnosed due in part to lack of resources, tools and time. Swedish startup War On Cancer wondered whether they could [...]

The social impact of data science: improving the mental health for cancer patients with AI was published on SAS Voices by Marinela Profi