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?
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.
+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.
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.
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.