BookmarkSubscribeRSS Feed
animesh123
Obsidian | Level 7

While trying to run this code I am geeting the below error

data oralib.benefeciary ;

set SSP.SSPSASSchemeBeneficiary(obs=10);

run;

ERROR: Error attempting to CREATE a DBMS table. ERROR: ORACLE execute error: ORA-00902: invalid datatype..

ERROR: ROLLBACK issued due to errors for data set ORALIB.SCHEMEBENEFICIA.DATA.

 

But running the below code is working 

data oralib.benefeciary ;(KEEP=AppId Disability DistrictName
DOB Gender GramPanchayatName MaritalStatus
SocialSchemeName);

 

set SSP.SSPSASSchemeBeneficiary(obs=10)


;

run;

 

But the length of the variable is jumping to anywhere around 800 for every variable

I had also tried to reduce  length   but the sameis not getting reduced

data oralib.Schemebeneview;
LENGTH Disability $15 DistrictName $15 GramPanchayatName $15 MaritalStatus $15
SocialSchemeName $15;
set oralib.SCHEMEBENEDETAIL;

RUN;

 

Could anyone please give an idea How to fix this?

 

4 REPLIES 4
Patrick
Opal | Level 21

Run your first code with below options which should show you in the log the create table statement that SAS actually generates.

options sastrace=',,,d' sastracelog=saslog nostsuffix; 
data oralib.benefeciary ;
  set SSP.SSPSASSchemeBeneficiary(obs=10);
run;

Is libref SSP pointing to a SAS table or is this also an Oracle table?

Please share with us the SAS generated Create Table statement from the log as well as the result from a Proc Contents for SSP.SSPSASSchemeBeneficiary.

And also: Which SAS version are you using. Is this SAS9.4, Viya SPRE or CAS?

 

I normally prefer to spend the extra effort to code an explicit pass-through create table statement instead of having SAS generate the code.

 

Quentin
Super User

+1 for using explicit pass-through.

 

Another option using implicit pass-through is to create the table in Oracle so you get all the types like you want, then use PROC APPEND in SAS to insert records into the existing oracle table.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
Tom
Super User Tom
Super User

If you want to have control over how SAS generates the SQL to create the variables you can use the DBTYPE= dataset option.

data oralib.Schemebeneview
(dbtype=(
  Disability=varchar2(15)
  DistrictName=varchar2(15)
  GramPanchayatName=varchar2(15)
  MaritalStatus=varchar2(15)
  SocialSchemeName=varchar2(15)
 )
);
  set oralib.SCHEMEBENEDETAIL;
run;

Make sure the types used are valid syntax for the target database.

 

Also if you have non-7bit ASCII characters in any of your strings and you are using a single byte encoding (suc as WLATIN1) and the database is using a multi-byte encoding (such as UTF-8) then make sure the target variables lengths reflect any extra bytes needed for those multibyte characters.

animesh123
Obsidian | Level 7

Hi - I have used this to fix the above issue in the Libname.

 

preserve_col_names=yes DB_LENGTH_SEMANTICS_BYTE=NO DBCLIENT_MAX_BYTES=1;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 805 views
  • 2 likes
  • 4 in conversation