BookmarkSubscribeRSS Feed
KirstenM
Calcite | Level 5

I have created a table in Oracle with a column FIELD1 which is defined as VARCHAR2(20 BYTE)  NOT NULL.

Users are able to append data to this table using SAS Enterprise Guide.

I need to prevent them from appending data where FIELD1 is blank.

However if the users make FIELD1 ='' in SAS (ie. blank or empty) they are able to append to the Oracle table so NOT NULL is not doing the trick. 

Appears that SAS interprets = ''  as a character field with a length of 1  rather than a null.

 

 

4 REPLIES 4
Tom
Super User Tom
Super User

In SAS there is no difference between an all blank character variable and missing value.  Character strings are fixed length.

.

So if you don't want them to insert blanks then tell them not to set the value to blanks.

 

I question the value of allowing the Oracle table to accept a value that is blank anyway as you seem to want to exclude missing values.  What is the difference between an all blank value and a null that you are trying to detect?  How are you going to tell the difference between a character string that is only blanks and one that is "empty"?

Tom
Super User Tom
Super User

SAS variables are fixed length and padded with spaces.  So assigning ' ' or '' to a character variable will result in all spaces.

 

You might try using the TRIMN() function.  That will return a completely empty string when the value only contains spaces.

 

insert into myora.mytable select id,trimn(name),age from have.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1064 views
  • 3 likes
  • 3 in conversation