10月 232018
 

This past Sunday was the last day of the NC State Fair, and we broke some records this year! Can you guess what those records were? I'll ramble on about the fair to give you time to come up with your guess, and then I'll let you know about the [...]

The post We broke some records at the 2018 NC State Fair! appeared first on SAS Learning Post.

10月 232018
 

I've been recovering for 15 years now, after a lengthy career caring for critically ill patients. Now, I’m part of a team at SAS that’s working to transform health care – and that's important to me because of something that happened when I was an ICU nurse. It changed my [...]

I am a recovering ICU nurse was published on SAS Voices by Heather Hallett

10月 232018
 

I've been recovering for 15 years now, after a lengthy career caring for critically ill patients. Now, I’m part of a team at SAS that’s working to transform health care – and that's important to me because of something that happened when I was an ICU nurse. It changed my [...]

I am a recovering ICU nurse was published on SAS Voices by Heather Hallett

10月 222018
 

Have you noticed a lot of graphs popping up lately, about politicians, voters, and elections? ... Well of course - it's an election year! If you follow my blog posts, then you're probably a bit "smarter than the average bear" when it comes to scrutinizing graphs. And election graphs election [...]

The post Which state has the oldest US Legislators? - Pick your graph axes carefully! appeared first on SAS Learning Post.

10月 222018
 

This blog post was also written by Reece Clifford.

Who’s responsible for x, y, z sales territory? What’s the most amount of people they engaged with in a month? What type of location leads to the best response from the meeting?

To get the complete answer to these sales team-related questions, you need to trust your data. You need to be able to cut and slice high-quality data to prepare for analytics to drive innovation in your company. With SAS Data Preparation alongside SAS Decision Manager, you can do all this. Its many features allow you to perform out-of-the-box column and row transformations to increase your data quality and build the foundations for data-driven innovation.

This blog will discuss how you can leverage SAS Decision Manager to enrich data when preparing it through SAS Data Preparation.

The use case

As posed above, we want to create a SAS Data Preparation plan to map a sales person to a postcode area. We use a SAS Decision Manager rule to find the sales person for a postcode area and map the person to the address. To trigger the rule, we are going to call it from SAS Data Preparation.

In SAS Decision Manager we import a csv file to create a Lookup Table mapping a sales person to a postcode area. Lookup Tables are tables of key-value pairs and provide the ability to access reference data from business rules.

Next, we create a rule to map a postcode and sales person. A rule specifies conditions to be evaluated and actions to be taken if those conditions are satisfied. Rules are grouped together into rule sets. Most rules correspond to the form:

if condition_expressions then action_expressions

For our rule, we are going to have an incoming postcode plus a record id. The postcode is assumed to be a UK postcode. We are extracting the first two characters of the postcode and lookup the sales person from the Lookup Table that we have just imported.

The rule outputs the sales person (representative) and the record ID. When we have tested and published the rule, it's ready to be used in a SAS Data Preparation Plan.

In SAS Data Preparation, we load a table with address data that we want to enrich by the appropriate sales person.

  1. We need to make sure the table column names and rule input parameter names match. Therefore, we are renaming the field ADDRESS_ID to ID, as ID is the rule input name. The second rule input parameter is Postcode which is the same as in the table, therefore no action is needed.

  1. We can then call the previously-created rule in SAS Decision Manager to map a sales person to an area. This will be done by adding some CASL code to the Code node in the SAS Data Preparation plan. This is featured below with a brief explanation of the functions.
    As the rule has two output parameters, we receive only two columns when executing the code step.

CASL Code

loadactionset "ds2";
action runModel submit / 
	modelTable={name="MONITORRULES", caslib="DCMRULES"}
	modelName="Mon_Person"
	table= {name= _dp_inputTable, caslib=_dp_inputCaslib}
	casout= {name= _dp_outputTable, caslib=_dp_outputCaslib};

Parameters settings for CASL call

modelTable name Name of the table where the rule set was published to.
modelTable caslib Name of the caslib where the rule set was published to.
modelName Name of the decision flow to execute.
table name Table name of the decision flow input data.

(Set to _dp_inputTable)

table caslib caslib name of the table input data.

(Set to _dp_inputCaslib)

casout name Table name of the decision flow output data.

(Set to _dp_outputTable)

casout caslib caslib name of the table output data.

(Set to _dp_outputCaslib)

 

Decision Manager Publishing Dialogue

 

  1. We then wanted to bring back the columns from the input table. We do this through joining the table in the SAS Data Preparation Plan to the original table (again) on the rule output field ID and the tables field ADDRESS_ID.

Conclusion

We have answered our initial question of which sales person is mapped to which region by enriching our data in a user-friendly, efficient process in SAS Data Preparation. We can now begin to gain further insight from our data to answer more of the questions posed at the beginning of the blog to help drive innovation. This can be done through additional insight using SAS Decision Manager or functions in SAS Data Preparation in the current plan or use the output table in another plan. Ultimately, this will facilitate data-driven Innovation via reporting or advanced analytics in your organisation.

Using SAS Decision Manager to enrich the data prep process was published on SAS Users.

10月 222018
 

A SAS programmer asked how to rearrange elements of a matrix. The rearrangement he wanted was rather complicated: certain blocks of data needed to move relative to other blocks, but the values within each block were to remain unchanged. It turned out that the mathematical operation he needed is called a block transpose. The BTRAN function in SAS/IML performs block-transpose operations, so the complicated rearrangement was easy to implement with a judicious call to the BTRAN function.

This article discusses the block-transpose operation and gives an example. It also shows how a block transpose can conveniently transform wide data into long data and vice versa.

The block-transpose operation

In general, a block matrix can contain blocks of various sizes. However, the BTRAN function requires that all blocks be the same size. Specifically, suppose A is a block matrix where each block is an n x m matrix. That means that A is an (r n) x (c m) matrix for some whole numbers r and c. The BTRAN function transposes the blocks to create a (c n) x (r m) block matrix.

The idea is more easily explained by a picture. The following image shows a matrix A that is composed of six blocks (of the same size). The block-transpose operation rearranges the blocks but leaves the elements within the blocks unchanged.

A block-transpose operation transposes the blocks but leaves the contents of each block unchanged

The BTRAN function in SAS/IML

Let's see how the block transpose works on an example in the SAS/IML language. The following statements create a 4 x 12 matrix. I have overlaid some grid lines to help you visualize this matrix as a 2 x 3 block matrix, where each block is 2 x 4.

proc iml;
x = repeat(1:12,2);
x = x // (10+x);
print x;
A 4x12 matrix visualized as a 2x3 block matrix. Each block is 2x4.

You can use the BTRAN function to apply a block transpose. The first argument is the matrix that contains the data. The second and third arguments specify the size of the blocks:

y = btran(x, 2, 4);    /* block size is 2x4 */
print y;
A 6x6 matrix visualized as a 3x2 block matrix. Each block is 2x4.

The output is a 6 x 6 matrix, visualized as a 3 x 2 block matrix.

Block transpose for wide-to-long transforms

If the number of rows in the block equals the number of rows in the data, then the BTRAN function stacks columns. In particular, if the block size is n x 1, the BTRAN function stacks multiple variables into a single column, just like the SHAPECOL function. For example, the Sashelp.Iris data contains four variables named SepalLength, SepalWidth, PetalLength, and PetalWidth. The following SAS/IML statements stack the four variables into a single column and create a new column that identifies the name of the original variable:

proc iml;
/* wide to long */
varNames = {"SepalLength" "SepalWidth" "PetalLength" "PetalWidth"};
use Sashelp.Iris;
   read all var "Species";        /* 150 x 3 */
   read all var varNames into X;  /* 150 x 4 */
close;
n = nrow(X); m = ncol(X);         /* n = 150; m = 4 */
 
ID = repeat(Species, m);          /* repeat the vars that are not transposed */
Var = shapecol(repeat(varNames, n), n*m); /* create column that contains variable names */
Value = btran(X, n, 1);           /* vector with 150*4 rows */ 
 
create test var {ID "Var" "Value"}; append; close;

Block transpose for wide-to-long transforms

In a similar way, you can transpose balanced data from long form to wide form. (Recall that "balanced data" means that each group has the same number of observations.) For example, the Sashelp.Iris data contains a Species variable. The first 50 observations have the value 'Setosa', the next 50 have the value 'Versicolor', and the last 50 have the value 'Virginica'. You can use a WHERE clause or a BY statement to analyze each species separately, but suppose you want to create a new data set that contains only 50 observations and has variables named SepalLengthSetosa, SepalLengthVersicolor, SepalLengthVirginica, and so forth for the other variables. The BTRAN function makes this easy: just specify a block size of 50 x 4, as follows.

/* create pairwise combinations of var names and group levels */
BlockRows = 50;
w = btran(X, BlockRows, m);                  /* 50 x 12 matrix */
 
s = Species[ do(1, n, BlockRows) ];          /* s = {'Setosa' 'Versicolor', 'Virginica'} */
vNames = rowcatc(expandgrid(varNames, s));   /* combine var names and species */
print vNames, w[c=vNames L="Measurenents (cm)"];

In summary, the BTRAN function is a useful function when you need to rearrange blocks of data without changing the values in a block. For balanced designs, you can use the BTRAN function to convert data between wide and long formats.

The post Transpose blocks to reshape data appeared first on The DO Loop.

10月 192018
 

Did you know that you can now chat with SAS Technical Support? Technical Chat enables you to quickly engage with a knowledgeable consultant when you have a SAS question or need help with troubleshooting an issue.

Technical Chat is a great tool for quick questions like these:

  • “What does this error mean?”
  • “How do I apply my new license?”
  • “What release of the operating system is supported on SAS® 9.4?”
  • “How do I activate JMP® without an internet connection?”
  • “Which function can I use to obtain the antilog of a value?”
  • “What is the status of my track?”

How to start a Technical Chat

To get started, click the orange Technical Chat button on select Technical Support web pages. Technical Chat is currently available in the United States and Canada, Monday–Friday from 9 a.m. to 6 p.m. Eastern Time. If the button is not available, technical assistance through other channels is listed on this SAS Technical Support page.  (And don't forget about SAS Support Communities -- peer-to-peer support that's available 24/7.)

Having trouble with a DATA step program or an ODS statement? Specialists in the areas of SAS programming, SAS Studio, and graphics might be available during select afternoon hours. When these specialists are available, you can request their assistance as soon as you click the Technical Chat button. When prompted with What is the nature of your inquiry?, select Usage of Base SAS, SAS/Studio or graphics. For all other questions, select All other products and/or tasks. Generalists are available throughout the day to answer questions.

Ensure that you have the following information available:

  • Site number
  • Operating system
  • Release of SAS, including the maintenance level

When the chat begins, the chat agent’s name appears at the top of the window, as in the following example:

Although every effort is made to resolve your question during the chat, sometimes the chat agent needs to open a track with a subject matter expert. Your question will still be addressed with the same urgency and professionalism that you are accustomed to when working with SAS Technical Support!

Your feedback counts!

When the chat is complete, you can request an emailed copy of the chat transcript. You can also rate your chat experience and provide feedback. Your responses are important to us as we continue to evaluate and improve our Technical Chat services.

Try it out. . . . Chat with SAS Technical Support!

Solve your SAS questions with Technical Chat was published on SAS Users.

10月 172018
 

Any of you who are even slightly into politics, or have followed any news lately, have probably seen something about the DNA test Elizabeth Warren took to prove/disprove her Native American ancestry. The test indicates she might have had a Native American ancestor 6 to 10 generations ago. That's a [...]

The post DNA and your family tree ... 6-10 generations back appeared first on SAS Learning Post.

10月 172018
 

What can you learn about wildfires when you provide a room full of analysts with 7 years of US wildfire data and the tools they need to analyze it? A lot. At a recent data dive, we plit 35 data scientists into 9 teams, provided multiple data sets containing information [...]

3 wildfire predictions from a recent SAS hackathon that might surprise you was published on SAS Voices by Alison Bolen