Hi,
I am loading a table in sql from a sasdataset. There are a few columns in the sql table with the datatype "text".
Those which are in sasdataset are "varchar" type. So when i try to load I am getting datatype mismatch. How to match the datatype of "varchar" in sas dataset with "text" column in sql table?
1) what code do you use?
2) what errors/log messages do you get?
3) what database?
Bart
what is the result of:
proc contents data=SAMPLE_DATA;
run;
(variables attributes)?
This is the output of proc contents
SAS Output | |||||
Alphabetic List of Variables and Attributes | |||||
Variable | Type | Len | Format | Informat | Label |
COL_VALUE_20 | Char | 10000 | $10,000.00 | ||
COL_VALUE_21 | Char | 10000 | $10,000.00 | ||
COL_VALUE_22 | Char | 10000 | $10,000.00 | ||
COL_VALUE_23 | Char | 10000 | $10,000.00 | ||
COL_VALUE_24 | Char | 200 | |||
COL_VALUE_25 | Char | 200 | |||
COL_VALUE_48 | Char | 10 | |||
COL_VALUE_49 | Char | 10 | |||
COL_VALUE_50 | Char | 10 |
ok, and what is the default length for COL_VALUE_20 variable in the SQL Server (the TEXT type variable in the system setup)?
Hello @sumi_saslearner
Have a look at the following reference
https://www.mssqltips.com/sqlservertip/2771/using-sas-access-and-proc-sql-to-save-sas-data-in-sql-se...
Please note SQL server does support varchar formats whereas in SAS, CAS supports varchar but not SAS 9.4 .
Holds a string with a maximum length of 65,535 bytes
I would first try using the DBTYPE= dataset option to tell SAS what database type should be used for those variables.
If that does not work then you might have to upload to an another table that has normal variables and then use pass thru SQL to copy into the target table with the TEXT variables.
How much data are you moving? if only a little the perhaps you can just generate the MS/SQL/SERVER code to insert the data and run that via SQL Pass thru.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.