Hi all,
I am running into problem. I have a ID fields eg: 0803M0000274 and 0526842935 in charc format and want to both convert it into numeric.
im using
INPUT(ID,BEST32.) as ID1 and this returns a blank for only alphanumeric field. How do i fix this. I m using Base SAS.
Help is appreciated.
are you sure you need a numeric subject id? i can't imagine why you would. but if you do: just create another numeric variable counting from 1 to n. i wouldn't tamper with the original id variable, eg you may later obtain new data (with the old id) and your only link will be the subject id, and many other unanticipated issues could arise eg if you converse with others who also access the data but have not recreated id in the same way .... etc
0803M0000274 can't be converted to numeric
Perhaps you could explain further what you would like when converting this to numeric.
In addition to the other comments suppose you actually have Ids of 0526842935 and 526842935. Converting these to numeric could very well lead to problems as the leading 0 in the first one is likely there for a reason.
DON'T DO THAT.
Imagine you also have an ID 0803N0000274.
ID's are character strings, you don't need them for calculating, so keep them as strings.
@viz2022 wrote:
Hi all,
I am running into problem. I have a ID fields eg: 0803M0000274 and 0526842935 in charc format and want to both convert it into numeric.
im using
INPUT(ID,BEST32.) as ID1 and this returns a blank for only alphanumeric field. How do i fix this. I m using Base SAS.
Help is appreciated.
I'm very much with @Kurt_Bremser. Why do you want to do this? Are you having a problem with leading zero's and ID's for the same person sometimes with and sometimes without leading zeros?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.