DATA Step, Macro, Functions and more

Reading numeric varible from excel

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 101
Accepted Solution

Reading numeric varible from excel

[ Edited ]

Reading numeric variable with commas into SAS 9.4 version.


Accepted Solutions
Solution
‎07-15-2016 06:56 AM
Super User
Super User
Posts: 7,392

Re: Reading numeric varible from excel

Your question is too vague.  What software are you using, how are you importing the data, what do you want the output to look like, what does the comma refence in this instance as some countries use , as decimal place for example.  If you just want to convert 18,5 to 18.5 do:

data want;
  set have;
  new_var=input(tranwrd(old_var,",","."),best.);
run;

View solution in original post


All Replies
Solution
‎07-15-2016 06:56 AM
Super User
Super User
Posts: 7,392

Re: Reading numeric varible from excel

Your question is too vague.  What software are you using, how are you importing the data, what do you want the output to look like, what does the comma refence in this instance as some countries use , as decimal place for example.  If you just want to convert 18,5 to 18.5 do:

data want;
  set have;
  new_var=input(tranwrd(old_var,",","."),best.);
run;
Super User
Posts: 9,662

Re: Reading numeric varible from excel

Try informat COMMAX.
Super User
Posts: 9,662

Re: Reading numeric varible from excel


data want;
  old_var='8.123,44';
  new_var=input(old_var,commax32.);
  format new_var comma32.2;
run;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 207 views
  • 0 likes
  • 3 in conversation