Here’s a situation that comes up pretty often. You receive a file that contains zip codes. It’s an excel file and you need to create a SAS data set out of it, so you can do some nifty market analysis. No problem, you clickety clickety through the SA…
Tag: function
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….
Data Steps 2010-07-19 22:25:00
I have a data set of sales data by day. Unfortunately the names of the columns represent the dates. In order to work with the data, I need to transform the data set so each day represents an observation.The data set looks something like this:store _0…
How to generate ICD9 table
data icd; infile ‘http://within.dhfs.state.wi.us/helpfiles/dlookupbrowse.html’ truncover; input star code $5. description $100.; if anyalpha(substr(code, 5, 1))=1 then addon=substr(code, 5, 1);run;data icd1; set icd nobs=nobs; code=compress(code, addo…
How to generate HCPCS 2009 long description
data two; infile ‘https://www.cms.gov/HCPCSReleaseCodeSets/Downloads/INDEX2009.pdf’ truncover; input @1 code $5. @7 description $200.; if code=’Page ‘ then delete; if code=’ ‘ then delete;run;proc sort data=two; by code;run;proc tr…
Online data collecting @indeed
FILENAME test URL “http://www.indeed.com/jobs?q=sas+programmer&limit=100&fromage=0&start=0” DEBUG LRECL=700;DATA test; infile test length=len; input record $varying700. len; *****DELETE MOST LINES W/O JOB;if index(record, ‘cmpid’)=0 th…
Finding the Max Value In An Array
The max() function makes it easy to find the maximum value in a SAS array. Given an array like:array x[*] x1-x10;maxValue = max(of x[*]);Pretty slick, eh? Remember, it doesn’t return the position of the max element, just the max value.This can be pret…
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 […]