Any suggestion for this question?
PROC SQL;
Connect to odbc(authdomain='sql_auth' datasrc='SQLA');
CREATE TABLE MY.test AS
SELECT * FROM CONNECTION TO odbc(
select
A.Location_Id,
A.Location_Name
from Location A
Where Active = 1
);
QUIT;
Result -
| Location_Id | Location_Name |
| FL | |
| OH | |
| IL | |
| HI | |
| CO |
How can I see the value of Location ID which is stored in Hex format?
Try this and see results in SAS
PROC SQL;
Connect to odbc(authdomain='sql_auth' datasrc='SQLA');
CREATE TABLE MY.test AS
SELECT * FROM CONNECTION TO odbc(
select
CONVERT(INT,A.Location_Id) as Location_Id,
A.Location_Name
from Location A
Where Active = 1
);
QUIT;
put(v1_hex||v2_hex, $hex8.) as
v1v2_char
Thank you for your help!
However, it doesn't work for me...... 😞
Hi,
Which database are you connecting to? Since your using Pass-Through query use DBMS specific function to convert the values before reading them into SAS.
Eg: CONVERT(INT,0xFFFFF) in Microsoft SQL Server
Us odbc connect to SQL database
Thanks for the help!
Try this and see results in SAS
PROC SQL;
Connect to odbc(authdomain='sql_auth' datasrc='SQLA');
CREATE TABLE MY.test AS
SELECT * FROM CONNECTION TO odbc(
select
CONVERT(INT,A.Location_Id) as Location_Id,
A.Location_Name
from Location A
Where Active = 1
);
QUIT;
I got someting back, but I'm expecting something like 0x000000000000001B, instead of 53, 54, 57.
Any idea?
Convert the Hexa to Char in database. Something like VARCHAR(MAX) instead of INT
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.