Tag: SAS Code

SAS / Teradata Fastexport – dbsliceparm = all

Fastexport is the fastest way to get large data out of teradata. Fastexport utilizes multiple connections to deliver data and therefore speeding up the transfer of data between Teradata and SAS. Here are a few examples of fastexport. /* libname statement*/ libname teradb  teradata username=&un password=&pw dbsliceparm=all; /* explicit sql */ proc sql; connect to […]

Default value to macro variable

NOTE: This is a great one we picked up from our friends over at the SAS community. We have run across this literally hundreds of times while programming SAS macros. You need to have a default value for a variable and you don’t want to write another macro to set it if it doesn’t exist. […]

SAS: Where Also

Ever heard of ‘where also’? Neither did we.
We have to give credit to the guys at the SAS Community.
‘Where also’ allows you to add a series of where statements. The use acts like a single where statement with the and condition….

“call symputX” is the symput upgrade

SymputX is the upgrade from Call Symput. Syntax: call symputx(“macro_var_name”, character_value (or numeric to be converted to char), symbol table def); Where symput will produce a note about converting character values to numeric, symputx won’t produce such a note. Additionally it will strip leading and trailing spaces form the character value. Lastly, you can define […]

Sending an email from SAS

Have you ever wanted to know when your code completes? Or maybe you want to automate the report to include sending an email? Regardless, SAS is happy to send that email for you. The easiest way to do this is through the SMTP access method via filename statements. Example: filename sendemail email ‘toaddress@email.com’ subject=’This is […]

SAS – Lowercase (lowcase) / Uppercase (upcase) / Proper Case (propcase)

We can’t stress the importance handling character case correctly. Here are the two functions you need to know and use correctly. In order to convert all characters in a sting to lowercase, use the LOWCASE function. Example: data ds_2; set ds_1; *convert it to lowercase; new_char_var=lowcase(OLD_CHAR_VAR); run; In order to convert all characters in a […]

SAS INTNX function ( add days, months, years, etc )

The INTNX function increments dates, times, or datetimes by specific or custom intervals. Here is the basic syntax for INTNX: INTNX(interval[multiple.shift-index], start, increment[, alignment]) The interval can be a set value like – DAY, WEEK, DTWEEK, YEAR, etc. You can also specify a custom interval. We will post more on that later. The multiple is […]

SAS DIM function – Counting the elements in an array

The DIM function returns the number of literal elements in an array. It functions against multi-dimensional arrays as well as one-dimensional arrays. 1-dimensional array example DIM(array_name) Multi-dimensional array examples DIM(m_array) -> returns the number of elements in the first dimension of the array DIM5(m_array) -> returns the number of elements in the 5th dimension of […]