| Date: | Wed, 14 Oct 2009 09:00:39 -0700 |
| Reply-To: | "Terjeson, Mark" <Mterjeson@RUSSELL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Terjeson, Mark" <Mterjeson@RUSSELL.COM> |
| Subject: | Re: Hexidecimal Conversion |
|
| In-Reply-To: | A<832f515e-1323-44d4-891b-2d9135c4d75c@h14g2000pri.googlegroups.com> |
| Content-Type: | text/plain; charset="us-ascii" |
Hi Paul,
Since you mention in paragraph one that you
are casting string to integer, I will presume
you want to convert to numeric in SAS as well
You can use
input(x,$HEX16.)
in both datastep or SQL expressions to do
the conversion. e.g.
* make a test string ;
data _null_;
x = '1234';
format x $HEX16.;
put _all_;
run;
* convert test string to numeric ;
data _null_;
x = '31323334';
y = input(x,$HEX16.);
put _all_;
run;
http://www.lexjansen.com/pnwsug/2006/PN20MarkTerjesonBinary.pdf
or
http://www.pnwsug.org/content/what-binary-what-hex
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:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
paulsparrow
Sent: Wednesday, October 14, 2009 8:30 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Hexidecimal Conversion
I have a SQL Server database that has an id field that is a BINARY
(HEX) format. In SQL I just do a CAST(field AS INT) to convert to an
integer.
In SAS through a PROC SQL how do I format or convert this field now
shown as $HEX16. in SAS.
|