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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 450 views
  • 3 likes
  • 3 in conversation