Category: SAS

Visual Analytics: Use Geo Regional Maps for Overall Comparisons

Before I started with SAS Visual Analytics, I used PROC GMAP to create choropleth maps (or geo regional maps). The maps worked for what I needed but were largely uninspired and somewhat difficult to build. I admit I never did master the skill. However, after learning to use SAS Visual Analytics geospatial objects became my favorite datavis. This is part 3 of a series about geospatial …

Post Visual Analytics: Use Geo Regional Maps for Overall Comparisons appeared first on BI Notes for SAS® Users. Go to BI Notes for SAS® Users to subscribe.

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

SAS MapReduce: A Quick Followup by DS2

(DS2 would be the king!) Years ago I made up a piece of SAS code to demonstrate the basic idea of Map-Reduce. Now this idea can be best implemented by this piece of workable program with PROC DS2 (tested in SAS 9.4 TS1M2, Win7): PROC DS2; /* create some data –*/ data input_data / overwrite […]

A Quick Look at SAS DS2 Merge

The code: data a;     input i a $ b $;     datalines;     1 a1A b1     1 a1A b1     2 a2 b2     ; run; data b;     input i a $ c $;     datalines;     1 a1C c1     2 .   c2     3 .  c3     ; run; data […]

Random Sampling: What’s Efficient?

Suppose you wish to select a random sample from a large SAS dataset.  No problem. The PROC SURVEYSELECT step below randomly selects a 2 percent sample: proc surveyselect data=large out=sample method=srs /* simple random sample */ n=1000000; /* sample size */ run; Do you have a SAS/STAT license?   If not, […]

The post Random Sampling: What’s Efficient? appeared first on SAS Learning Post.

What’s wrong with this SAS program?

I think everyone can agree that being able to debug programs is an important skill for SAS programmers. That’s why Susan Slaughter and I devoted a whole chapter to it in The Little SAS® Book. I don’t know about you, but I think figuring out what’s wrong with my program […]

The post What’s wrong with this SAS program? appeared first on SAS Learning Post.

Analytics 2015 lands in Rome on Nov. 9-11

The digital disruption phenomenon is redrawing the market map. New players, products and services are gaining competitive advantage, while traditional business and revenue models are being questioned. Gartner believes that by 2020, thanks to the Internet of Things, information will be used to reinvent, digitalize or eliminate 80% of business […]

The post Analytics 2015 lands in Rome on Nov. 9-11 appeared first on SAS Learning Post.

SAS macros always have a global scope

SAS allows the programmer to declare the scope of macro variables using %LOCAL or %GLOBAL, but the macros themselves are always created in the global scope.

Say you have a macro that in another language, say Python, would be considered a function. Within the macro you want a sub-macro (i.e., sub-function) to be used only within the outer macro.


%macro outer;
%put NOTE: outer;

/* This "sub-macro" is defined within the outer macro and is
intended only for use within the outer macro. */
%macro inner(foo);
%put NOTE: inner &foo;
%mend;

%inner(1);
%inner(2);
%mend;

%outer;

/* If the "sub-macro" has a local scope, the next step would fail */
%inner(3);

/* However, it succeeds */

This can lead to conflicts if the macro %inner is defined somewhere else in the same session. One way of dealing with this is to be careful to give the inner macro a unique name like __outer_inner where the underscores in the prefix suggest a local scope, and adding outer to the macro name indicates the macro is to be used only in the outer macro.

Another option is to use the %sysmacdelete to delete the inner macro:


%macro outer;
%put NOTE: outer;

%macro inner(foo);
%put NOTE: inner &foo;
%mend;

%inner(1);
%inner(2);
/* Delete the inner macro */
%SYSMACDELETE inner;
%mend;

%outer;

/* This fails because of SYSMACDELETE */
%inner(3);

Tested with SAS 9.4M3 on Windows 7.

For more posts like this, see Heuristic Andrew.

Serving up SAS training in cities near you

The 2015 United States Tennis Open tournament is now underway, and like most tennis fans, I’ve got my eyes on women’s tennis great Serena Williams, as she attempts to make history by winning the tournament and achieving a calendar Grand Slam. What are her chances of reaching the milestone?  Most […]

The post Serving up SAS training in cities near you appeared first on The SAS Training Post.