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

I am attempting to perform an update statement via proc sql on an existing table stored in SQL Server. The table I am writing to does not allow null values in any fields but has numerous records with blank values. When I attempt to update some records, I receive an error that the fields do not accept null values. Some fields in the table I am updating from have empty strings, but no null values. I even have forced them to be empty strings by performing a statement like "CASE WHEN col1 is null then '' else col1 end". When I look at the table I am updating from in another program (Advanced Query Tool), I still see null values where empty strings should be, whereas the table I am updating to shows empty strings.

 

What option do I need to change to get SAS to write empty strings instead of nulls to a SQL Server table?

AQT shows (null)AQT shows (null)SAS EG shows empty stringSAS EG shows empty string

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why did you try to add those to the PROC SQL statement?

Aren't those either connection options

libname mylib sqlserver ... nullchar=no ;

or dataset options?  

proc sql;
create table mylib.mytable(nullchar=no) as
  select *,' ' as empty_var
  from sashelp.class
;
quit;
  

 

View solution in original post

3 REPLIES 3
Placeholder
Calcite | Level 5

Thanks for the links. It appears both options are valid when using the proc step, but when I attempt to use either one in my code, I receive the following error:

 

29 proc sql nullcharval=no;
___________
22
202
ERROR: Entry NO.TRANTAB not found in catalog SASHELP.LOCALE.

 

 

29 proc sql nullchar=no;
________
22
202
ERROR: Entry NO.TRANTAB not found in catalog SASHELP.LOCALE.

Tom
Super User Tom
Super User

Why did you try to add those to the PROC SQL statement?

Aren't those either connection options

libname mylib sqlserver ... nullchar=no ;

or dataset options?  

proc sql;
create table mylib.mytable(nullchar=no) as
  select *,' ' as empty_var
  from sashelp.class
;
quit;
  

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 3261 views
  • 2 likes
  • 2 in conversation