SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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