The post Stratified random sample: What's efficient? appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
In a previous blog, Random Sampling: What’s Efficient?, I discussed the efficiency of various techniques for selecting a simple random sample from a large SAS dataset. PROC SURVEYSELECT easily does the job: proc surveyselect data=large out=sample method=srs /* simple random sample */ rate=.01; /* 1% sample rate */ run; Note: […]
The post Stratified random sample: What’s efficient? appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
The post Kick off your SAS Global Forum journey with a SAS Certification appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
We are a few months away from SAS Global Forum in Orlando. You might think that the conference kicks off Sunday night at opening session, but there are plenty of weekend activities before then and I’d like to highlight one of them: SAS certification exam sessions. Isn’t now a great […]
The post Kick off your SAS Global Forum journey with a SAS Certification appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
The post Five reasons to check out the new SAS analytical documentation appeared first on The DO Loop.
]]>This post was kindly contributed by The DO Loop  go there to comment and to read the full post. 
The SAS analytical documentation has a new look.
Beginning with the 14.2 release of the SAS analytical products (which shipped with SAS 9.4m4 in November 2016), the HTML version of the online documentation has moved to
a new framework called the Help Center. The URL for the online documentation is easy to remember:
http://support.sas.com/documentation/
This article shows the 14.2 documentation for the SAS analytical products, as highlighted in the adjacent image. Documentation for previous releases is also available.
The 14.2 link takes you to a new page that contains links for the User’s Guides for each SAS analytical product, such as SAS/STAT, SAS/ETS, SAS/IML, and so on.
When you click on a User’s Guide, you are taken to the new Help Center.
An example page for the SAS/STAT documentation is shown in the following image (click to enlarge). As in previous versions of the help system, the Help Center provides dropdown lists (Overview, Getting Started, Syntax, etc.) for quick navigation within a procedure. There are also arrows (now in the upper right corner) that take you to the previous or next page in the book.
The following list describes five features of the Help Center that are either new or that extend features of the older HTML format. The locations of these features are highlighted with red rectangles in the previous image.
Five new features in the #SAS analytical documentation
Click To Tweet
Enhanced search within a book: In the older HTML doc, search results appear on a separate HTML page. In the new Help Center, the search facility (click the magnifying class icon or CTRL+SHIFT+S) displays the results in a popup scrollable window as shown in the adjacent image. When you click a search result, the Help Center updates to display the new page. If you search again, the search window remembers your previous query. If you want to close the search window, press the ESC key. The search facility supports complex expressions, Boolean operators, and proximity searches.
In summary, the new Help Center framework provides additional ways for SAS customers to learn about the syntax, options, and output of SAS analytical procedures.
At the present time, only analytical products use the Help Center. The documentation for Base SAS continues to be provided in HTML and PDF formats.
Check out the SAS analytical products 14.2 documentation and let me know what you think. Do you like something that I didn’t mention? Post a comment.
The post Five reasons to check out the new SAS analytical documentation appeared first on The DO Loop.
This post was kindly contributed by The DO Loop  go there to comment and to read the full post. 
The post Explaining analytics? Maybe you should think about the narrative appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
I continue to find the concept of explaining analytics through storytelling intriguing. As I have written before, at first blush this did not seem immediately clear to me. The advice to use storytelling appeared somewhat vague, trite and without substance. More importantly, it seemed to conflict with the rigor required […]
The post Explaining analytics? Maybe you should think about the narrative appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
The post How do teenage boys eat so much, and stay so thin? appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
“They’ll eat you out of house & home! Their food bill will put you in the poor house! … And they never gain an ounce!” – That’s what my friends say about their teenage sons. They’re probably exaggerating a little, but since it’s a recurring theme, there’s probably some truth […]
The post How do teenage boys eat so much, and stay so thin? appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
The post Where does Girl Scout cookie money go? appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
Here in the US, it’s Girl Scout cookie season. This is when you get to spend a few bucks on cookies, break your New Year’s resolution about losing weight … and feel good about it, because the money’s going to a good cause. Or is it? – Let’s break down […]
The post Where does Girl Scout cookie money go? appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
The post Solve mixedinteger linear programming problems in SAS appeared first on The DO Loop.
]]>This post was kindly contributed by The DO Loop  go there to comment and to read the full post. 
This article shows how to solve mixedinteger linear programming (MILP) problems in SAS. In a mixedinteger problem, some of the variables in the problem are integervalued whereas others are continuous. The objective function is a linear function of the variables and the variables can be subject to linear constraints.
Last month I discussed how to solve linear programming (LP) problems in SAS by using PROC OPTMODEL in SAS/OR or by using SAS/IML software.
You can use these same tools to solve mixedinteger linear programming problems.
The OPTMODEL procedure has the simpler syntax.
The MILPSOLVE function in SAS/IML software provides similar functionality in a n interactive matrix language.
The previous article solved a twovariable LP problem. If you constrain one of the variables to be an integer, you get a MILP problem, as follows:
The graph shows the feasible region. The interior of the polygon satisfies the constraints. Because x1 must be an integer, the vertical stripes indicate the feasible values of the variables. The color of the stripes indicate the value of the objective function. The green star indicates the optimal solution, which is
x = {5, 3.1}.
The following statements show one way to formulate and solve the MILP problem by using the OPTMODEL procedure in SAS/OR software:
proc optmodel; var x1 integer >= 0; /* information about the variables */ var x2 >= 0; max z = 3*x1 + 5*x2; /* define the objective function */ con c1: 3*x1 + 2*x2 <= 10; /* specify linear constraints */ con c2: 5*x1 + 10*x2 <= 56; con c3: 4*x1 + 2*x2 >= 7; solve with milp; /* solve the MILP problem */ print x1 x2; quit; 
The OPTMODEL procedure prints two tables. The first (not shown) describes the optimization algorithm and tells you that the optimal objective value is 30.5. The second table is the solution vector, which is
x = {5, 3.1}.
The MILPSOLVE subroutine in the
SAS/IML language uses matrices and vectors to specify the problem. The syntax for the MILPSOLVE subroutine is almost identical to the syntax for the LPSOLVE subroutine, so see the previous article for an explanation of each argument.
The following SAS/IML program defines and solves the MILP problem:
proc iml; /* information about variables (row of column, doesn't matter) */ colType = {I, C}; /* C, B, or I for cont, binary, int */ LowerB = {0, 0}; /* lower bound constraints on x */ UpperB = {10,10}; /* upper bound constraints on x */ /* objective function */ c = {3 5}; /* vector for objective function c*x */ /* linear constraints */ A = {3 2, /* matrix of constraint coefficients */ 5 10, 4 2}; b = {10, /* RHS of constraint eqns (column vector) */ 56, 7}; /* specify symbols for constraints: 'L' for less than or equal 'E' for equal 'G' for greater than or equal */ LEG = {L, L, G}; /* control vector for optimization */ ctrl = {1, /* maximize objective */ 1}; /* print level */ CALL MILPSOLVE(rc, objVal, result, relgap, /* output variables */ c, A, b, /* objective and linear constraints */ ctrl, /* control vector */ coltype, LEG, /*range*/, LowerB, UpperB); print rc objVal, result[rowname={x1 x2}]; 
In the call to MILPSOLVE, the first four arguments are output arguments. The return code (rc) is 0, which indicates that an optimal value was found.
The value of the objective function at the optimal value is returned in objVal.
The optimal values of the variables are returned in the result argument.
The MILPSOLVE subroutine was introduced in SAS/IML 13.1, which was shipped with SAS 9.4m1.
For additional details about the MILPSOLVE subroutine, see the documentation.
The post Solve mixedinteger linear programming problems in SAS appeared first on The DO Loop.
This post was kindly contributed by The DO Loop  go there to comment and to read the full post. 
The post Prius isn't the highestmpg hybrid in 2017! appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
For many years, the Toyota Prius was the hybrid with the best mpg – but in 2017 that’s changing! Let’s examine the data … For analyses like this, I have found the fueleconomy.gov website to be a wonderful source of information. In recent years, they’ve even made all their data […]
The post Prius isn’t the highestmpg hybrid in 2017! appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
The post PUT it there! Six tips for using PUT and %PUT statements in SAS appeared first on The DO Loop.
]]>This post was kindly contributed by The DO Loop  go there to comment and to read the full post. 
For SAS programmers, the PUT statement in the DATA step and the %PUT macro statement are useful statements that enable you to display the values of variables and macro variables, respectively. By default, the output appears in the SAS log. This article shares a few tips that help you to use these statements more effectively.
The PUT statement supports a “named output” syntax that enables you to easily display a variable name and value. The trick is to put an equal sign immediately after the name of a variable: PUT varname=;
For example, the following statement displays the text “z=” followed by the value of z:
data _null_; x = 9.1; y = 6; z = sqrt(x**2 + y**2); put z=; /* display variable and value */ run; 
z=10.9 
You can extend the previous tip to arrays and to sets of variables.
The PUT statement enables you to display elements of an array (or multiple variables) by specifying the array name in parentheses, followed by an equal sign in parentheses, as follows:
data _null_; array x[5]; do k = 1 to dim(x); x[k] = k**2; end; put (x[*]) (=); /* put each element of array */ put (x1 x3 x5) (=); /* put each variable/value */ run; 
x1=1 x2=4 x3=9 x4=16 x5=25 x1=1 x3=9 x5=25 
This syntax is not supported for _TEMPORARY_ arrays. However, as a workaraound, you can use the CATQ function to concatenate array values into a character variable, as follows:
temp = catq('d', ',', of x[*]); /* x can be _TEMPORARY_ array */ put temp=; 
Incidentally, if you ever want to apply a format to the values, the format name goes inside the second set of parentheses, after the equal sign: put (x1 x3 x5) (=6.2);
The previous tip displayed all values on a single line. Sometimes it is useful to display each value on its own line. To do that, put a slash after the equal sign, as follows:
... put (x[*]) (=/); /* put each element on separate lines */ ... 
x1=1 x2=4 x3=9 x4=16 x5=25 
You can display all values of all variables by using the _ALL_ keyword, as follows:
data _null_; x = 9.1; y = 6; z = sqrt(x**2 + y**2); A = "SAS"; B = "Statistics"; put _ALL_; /* display all variables and values */ run; 
x=9.1 y=6 z=10.9 A=SAS B=Statistics _ERROR_=0 _N_=1 
Notice that in addition to the userdefined variables, the _ALL_ keyword also prints the values of two automatic variables named _ERROR_ and _N_.
Just as the PUT statement displays the value of an ordinary variable, you can use the %PUT statement to display the value of a macro variable. If you use the special “&=” syntax, SAS will display the name and value of a macro variable. For example, to display your SAS version, you can display the value of the SYSVLONG automatic system macro variable, as follows:
%put &=SYSVLONG;

SYSVLONG=9.04.01M4P110916
The results above are for my system, which is running SAS 9.4M4. Your SAS version might be different.
You can display the name and value of all userdefined macros by using the _USER_ keyword. You can display the values of all SAS automatic system macros by using the _AUTOMATIC_ keyword.
%let N = 50; %let NumSamples = 1e4; %put _USER_; 
GLOBAL N 50 GLOBAL NUMSAMPLES 1e4
There you have it: six tips to make it easier to display the value of SAS variables and macro variables.
Thanks to Jiangtang Hu who pointed out the %PUT &=var syntax in his blog in 2012.
For additional features of the PUT and %PUT statements, see:
The post PUT it there! Six tips for using PUT and %PUT statements in SAS appeared first on The DO Loop.
This post was kindly contributed by The DO Loop  go there to comment and to read the full post. 
The post What to do in Orlando, during SAS Global Forum! appeared first on SAS Learning Post.
]]>This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 
They say “a picture is worth 1000 words” – and I think it might be more like 2000 when it comes to planning out fun/interesting things to do in a new city! I’m going to the SAS Global Forum (#SASGF) conference in Orlando this year, and I was wondering where […]
The post What to do in Orlando, during SAS Global Forum! appeared first on SAS Learning Post.
This post was kindly contributed by SAS Learning Post  go there to comment and to read the full post. 