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 (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info 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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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