Navigating SAS Documentation

Reply
Contributor kbk
Contributor
Posts: 29

Navigating SAS Documentation

As a new SAS user I am still figuring out the best way to find answers when I need to. I was hoping to gain suggestions from other users on how they search the documentation, forums or random corners of the web.  I'll put forth an example of information I am currently seeking.

It is possible to 'or' multiple statements in an if statement in at least two ways. From what I can see, the following are functionally identical:

if country = 'CA' or country = 'US' then do;

if country in ('CA','US') then do;

The first example is fairly self explanatory. The use of parentheses is new to me and I have been trying to find more information on this. For example, it would be nice to know if there is a way to put conditions into a set of parentheses but yield an 'and' operator.

I've tried search the SAS documentation but it is pretty bad at bringing back relevant hits.

Googling brought me to the appropriate SAS documentation page but there is no mention of the parenthetic OR operator. I have also looked over the SAS Operators page.

I've tried other Google searches, going so far as to exclude all SAS websites (-site:sas.com) and all pdfs (-filetypeSmiley Tonguedf) to focus on blogs and forums but I haven't had luck.

I would like to know more about the parenthetic Or statement but more importantly - How do I find the answer myself!?!?  I am sure it is available somewhere.

[Edit: At one point I found this searchable email archive. Are there other listserves commonly used for exchange among SAS users?]

PROC Star
Posts: 7,467

Re: Navigating SAS Documentation

Welcome to why the learning curve is so steep for SAS .. there is simply an awful lot there to learn.

You looked for the wrong thing.  It isn't really an alternative us of or but, rather, an operator by itself.  And, yes, there are even more ways in can be used such as with an array (which, surprisingly, doesn't require parentheses.

Take a look at: SAS(R) 9.2 Language Reference: Concepts, Second Edition

Trusted Advisor
Posts: 2,115

Re: Navigating SAS Documentation

As Art says, there is a lot to learn.  You may want to start with a basic "book by users" to get you over the hump.  (Google <code site:sas.com> or <delwiche site:sas.com> for the author pages of two people who write clear introductory books.)

SAS is a language, so one of the keys to searching is to understand the 'parts of speech' to make your searches more precise.  For instance, IF is a "statement", so searching

if statement site:sas.com

is quite useful for the general syntax.  Similarly, "=" or "eq", and "|" or "or" are "operators", so searching

eq operator site:sas.com

gets you right to how to understand operators in expressions (An "expression" is the "part of speech" between the IF and the THEN parts of the statement.).  "in" is a function.

These are all in the language reference that Art recommends.  It's complete (and a bit overwhelming for a new user).

Doc Muhlbaier

Duke

Update:  IN is also an operator.  (IN function is different and unsupported in SAS).  Thanks, Art.

Message was edited by: Lawrence Muhlbaier

Super User
Posts: 5,495

Re: Navigating SAS Documentation

Ah, just wait until you discover that variable names are not restricted.  This would be a perfectly legal SAS statement:

do do=to to to by by;

Good luck to all of us!

Trusted Advisor
Posts: 2,115

Re: Navigating SAS Documentation

Posted in reply to Astounding

Astounding, that is cruel!  :smileydevil:  --Doc

PROC Star
Posts: 7,467

Re: Navigating SAS Documentation

He could have been even nastier!  Another thing that makes the learning curve even steeper is the fact that SAS will accept some misspellings.

The following will work, albeit with a couple of warnings:

data test;

  sete sashelp.class (rename=(age=to weight=by));

  doe do=to to to by by;

    if do eq to the by=1;

  endd;

run;

Super User
Posts: 5,495

Re: Navigating SAS Documentation

Art,

I have to give credit to Rick Aster for this one ... SAS will accept POTIONS as an alternate spelling of OPTIONS.

Super User
Posts: 11,336

Re: Navigating SAS Documentation

Posted in reply to Astounding

And

Data do.to;

     set to.do;

I bet I could make a case for an SCL statement using do.do.do.do somewhere.

Super User
Super User
Posts: 7,035

Re: Navigating SAS Documentation

Posted in reply to Astounding

I had a friend who would end a meeting when ever someone used "do do" in a sentence.  (Or at least pretend be offended such language!)

Contributor kbk
Contributor
Posts: 29

Re: Navigating SAS Documentation

I'm tempted to set Tom's response as the correct answer.

Ask a Question
Discussion stats
  • 9 replies
  • 345 views
  • 1 like
  • 6 in conversation