| Date: | Wed, 14 Oct 2009 16:17:09 -0700 |
| Reply-To: | paulsparrow <paulsparrow@TELUS.NET> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | paulsparrow <paulsparrow@TELUS.NET> |
| Organization: | http://groups.google.com |
| Subject: | Re: Hexidecimal Conversion |
|
| Content-Type: | text/plain; charset=ISO-8859-1 |
On Oct 14, 3:46 pm, Mterje...@RUSSELL.COM ("Terjeson, Mark") wrote:
> Hi Paul,
>
> You can solve this two ways:
>
> On the SQLSVR side:
>
> just use cast(wasBinary as integer)
> and cast it to integer before going to SAS.
> e.g.
>
> select cast(wasBinary as integer) as nowInteger
> from (--test data
> select cast(27 as binary) as wasBinary
> ) as a
>
> On the SAS side:
>
> just use input(fromsqlsvr,hex16.)
> in datastep code or SQL code. e.g.
>
> data _null_;
> fromsqlsvr = '0000000000001B';
> myinteger = input(fromsqlsvr,hex16.);
> put _all_;
> run;
>
> Hope this is helpful.
>
> Mark Terjeson
> Investment Business Intelligence
> Investment Management & Research
> Russell Investments
> 253-439-2367
>
> Russell
> Global Leaders in Multi-Manager Investing
>
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of
>
> paulspar...@telus.net
> Sent: Wednesday, October 14, 2009 1:29 PM
> To: SA...@LISTSERV.UGA.EDU
> Subject: Re: Hexidecimal Conversion
>
> This is my issue. IN SQL SERVER the data field is a BINARY format.
> When I look at it in SAS through ODBC it is a $HEX16. (in otherwords
> a charactor).
>
> CAST(field as INT) in SQL gives me an integer of the field.
>
> I have tried PUT(field,$HEX16.) and it returns exactly what I pullled
> already. Example 0000000000001B What I need is the integer equvilant
> of say 123 (or what ever it equals)
>
> Sorry but I'm not a brain at this stuff.- Hide quoted text -
>
> - Show quoted text -
Yes I finally looked back at some old code and I can CAST it in SQL
before bringing it back. Thanks.
PROC SQL;
Connect to odbc("DSN=nscupink;");
Create table bird.conv01c as
select
member_id
from connection to odbc (
select
CAST(RM.CONTACT_ID as INT) as member_id
FROM
dbo.contact rm
)
;
QUIT;
|