turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- If Open_date is non-numeric coding?

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-27-2017 11:06 AM

Hi SAS Forum,

I was asked to code the following wording in SAS.

if (DATE_OPEN is blank or non-numeric)

then New_variable = **0**

Q: It is very easy to code the blue color portion, but I do not know how to code the red color portion. Could someone help me.

if (DATE_OPEN = ' ' or non-numeric)

then New_variable = **0**

Thanks

Mirisa

Accepted Solutions

Solution

03-27-2017
09:26 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to dunga

03-27-2017 11:33 AM

There are number of ways to see if a variable could be numeric. Easiest might be to attempt a conversion to numeric and see if the result is missing or not.

See if

or (input(date_open,best16.) = .)

works for your data.

However since you have a variable that has DATE in the name then we might need to consider what you might mean by "non-numeric" if the value is something like 01/25/2017 or 3Jan2017.

Also does your definition of "nonnumeric" exclude all forms that may have non-digits such as an arithmetic operation "3+5", or data such as 1.3E12? Some time clarification of terms is needed as they can get situational for data processing.

All Replies

Solution

03-27-2017
09:26 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to dunga

03-27-2017 11:33 AM

There are number of ways to see if a variable could be numeric. Easiest might be to attempt a conversion to numeric and see if the result is missing or not.

See if

or (input(date_open,best16.) = .)

works for your data.

However since you have a variable that has DATE in the name then we might need to consider what you might mean by "non-numeric" if the value is something like 01/25/2017 or 3Jan2017.

Also does your definition of "nonnumeric" exclude all forms that may have non-digits such as an arithmetic operation "3+5", or data such as 1.3E12? Some time clarification of terms is needed as they can get situational for data processing.