@Khalidhamad wrote:
I want to manipulate the dataset to get rid of the before and after character and then change it to numeric. the variable is like this Census Tract 1, Chaffee County, Colorado. and I just want to have the number and get rid of the rest and then change to numeric. Thank you
Actual examples of the values to manipulate and what the expected result should be in the form of data step code will get you a better response.
Unfortunately data values in the middle of narrative sentences open all sorts of questions about just where does your value start and end. Not really clear as such.
If you are not doing arithmetic with something identifiers seldom are better as numeric values.
data example;
sometext='A value with numerals 1234 in the middle';
justthenumerals = compress(sometext,,'dk');
numericvalue = input(justthenumerals,6.);
run;
The above code 1) provides an example value, 2) uses the Compress function to Keep only Digits and then 3)converts the digits to a numeric value
Caution: This approach will only yield your apparent desire if there is only set of numerals in the string as this keeps ALL numerals.
Once a variable type is set you cannot change the type in SAS. So you need to create a new variable.