Category: SAS

MDY Function

The MDY function converts MONTH, DAY, and YEAR values to a SAS date value. For example, MDY(10,19,1999) returns the SAS date value ’19OCT99’D.

Syntax:    MDY(month,day,year)

Arguments

month : specifies a numeric expression t…

Find Documentation for SAS Functions

A few weeks ago, I answered the question How do I find documentation for SAS Procedures? Earlier this week, another question was submitted by a site visitor. This time, the customer is looking for a list of SAS macros.

Q: I am trying to locate…

SAS EG: Filtering a dataset via prompt manager variable

Nobody who reads this blog is likely a SAS programmer. However, on the off chance this would be useful to someone who finds it via Google, I wanted to post. Currently, I am working on a project in SAS Enterprise Guide where I needed to allow the user to provide variable value(s) via prompt manager […]

SAS—your wish is my command

I love to teach SAS programming and in this blog, I hope to share best practices, tips, tricks and answer some frequently asked questions by our SAS users. I’m constantly learning more nuances of SAS and more programming languages like SQL. Why …

Locked out of updating SAS OLAP cubes?

Developing an OLAP cube, testing in Enterprise Guide or Web Report Studio, and suddenly you begin getting error messages from rebuilding the OLAP Cube stating that it’s locked. Now what do you do? Restart the OLAP Server? Well, if you don’t have access…

Power of Logic Operators: a trick

Suppose you should group people based on their ages as follows:

ID
Age
agegrp

001
1
1

002
4
2

003
5
2

004
5
2

005
2
1

006
4
2

007
5
2

008
2
1

009
9
3

010
8
3

and the rules:
age<4,           group 1
4<=age<6,     group 2
6<=age<10,  group 3
It is a very simple question and you could use the if/else statement without thinking:
data age;
input ID $ age;
datalines;
001 1
002 4
003 5
004 5
005 2
006 4
007 5
008 2
009 9
010 8
;
data age1;
set age;
if age<4   then agegrp=1;
else if […]

SAS multiple character and varying length Delimiters

I’ve solved a problem I had in my previous post “Strip Characters From Between Two Delimiters”.  At work I was given a strangely formatted data file – example.
I needed to separate out the data chunks to work with it.  While my first solution…