Hello,
May you help with following converting the characer value with decimal into numeric value:
test = input( price, best12.) , it did not work.
Price: Format $7, informat $7.
example of price : 6.32, 0.11, 0.44, 11.73
Thank you.
Ivy
Works for me. I'd have to think that you entered something wrong (e.g., missing semi-colon or the like).
The following works:
data have; format price $7.; informat price $7.; input price; cards; 6.32 0.11 0.44 11.73 ; data want; set have; test = input( price, best12.); run;
Art, CEO, AnalystFinder.com
Works for me. I'd have to think that you entered something wrong (e.g., missing semi-colon or the like).
The following works:
data have; format price $7.; informat price $7.; input price; cards; 6.32 0.11 0.44 11.73 ; data want; set have; test = input( price, best12.); run;
Art, CEO, AnalystFinder.com
Your example statement should work. Make sure that your text string does not have non-printing characters like tabs, carriage returns or non-breaking spaces ('09'x,'0A'x,'A0'x, respectively).
data want ;
length price $7 ;
input price ;
test = input(price, 7.);
cards;
6.32
0.11
0.44
11.73
;;;;
A couple of notes.
To see if your strings have non-printing characters print the value using $HEX format. '20'X is the code for a space.
Or you the COMPRESS() function to remove non digits. Something like this might help.
test = input(COMPRESS(price, "+.-", "d"),32.);
Doesn't work is awful vague.
Are there errors in the log: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Also is your value for Price= '6.32' or '$6.32'? or does your Price have values separated by commas? Leading spaces? It isn't quite clear from your example.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.