Tag: functions

NOTE: The PROPCASE Function

Here’s just a brief post about a function I just stumbled across. The PROPCASE function coverts a string to “proper case” wherein the first letter of each word is upper case and all others are lower case. Clearly this is a very useful thing for column …

Use BYTE function to create special ASCII character, e.g. plus/minus sign

data _null_;&nbsp &nbsp &nbsp do i=0 to 255;&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp x=byte(i);&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp put i= x=;&nbsp &nbsp &nbsp end;&nbsp &nbsp &nbsp y=rank(‘a’);&nbsp &nbsp &nbsp put y=;run;BYTE function results:i=65 — 90 x=…

LAG function

LAG Function (SAS 9.2 Doc)*** Use a third variable to assign the value from the previous record;array one a b c d;array two e f g h;&nbsp &nbsp &nbsp do over one;&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp temp = lag(one);&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if…

Generate random numbers

options pageno=1 nodate ls=80 ps=64;data u1(keep=x);&nbsp &nbsp &nbsp seed = 104;&nbsp &nbsp &nbsp do i = 1 to 5;&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp call ranuni(seed, x);&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp output;&nbsp &nbsp &nbsp end;&nbsp &nbsp &nbsp…

Example 8.8: more Hosmer and Lemeshow

This is a special R-only entry.In Example 8.7, we showed the Hosmer and Lemeshow goodness-of-fit test. Today we demonstrate more advanced computational approaches for the test.If you write a function for your own use, it hardly matters what it looks l…

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 […]