BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dunga
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

1 REPLY 1
ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 318 views
  • 0 likes
  • 2 in conversation