BookmarkSubscribeRSS Feed
viz2022
Calcite | Level 5

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. 

 

5 REPLIES 5
pau13rown
Lapis Lazuli | Level 10

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

PaigeMiller
Diamond | Level 26

0803M0000274 can't be converted to numeric

 

Perhaps you could explain further what you would like when converting this to numeric.

--
Paige Miller
ballardw
Super User

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.

Kurt_Bremser
Super User

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. 

 


 

Patrick
Opal | Level 21

@viz2022

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?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 596 views
  • 0 likes
  • 6 in conversation