While trying to run this code I am geeting the below error
data oralib.benefeciary ;
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
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
LENGTH Disability $15 DistrictName $15 GramPanchayatName $15 MaritalStatus $15
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.
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.