Question

I'm trying to pull data stored as $24. I want to convert it from character to numeric. The input(variable-name,comma24.) function is not working for me. A sample of the data is given below.

5.35 5.78 413,000 3,280,000 5.97 6.72 5 6.53 6 4.59 4.25 5 6.38 6.41 4.1 6.56 5.45 6.07 4.28 5.54 5.87 3.88 5.53 5.65 6.47 207,000 4,935,000 4,400,000 6,765,000 2,856,000 53,690,000

Was it helpful?

Solution

You don't show your code, but for some reason I could get it work when the reading and conversion were in different data steps, but not when it was the same data step.

The following works just fine:

DATA one;
  INPUT y: $24. @@;
DATALINES;
5.35 5.78 413,000 3,280,000 5.97
RUN;

DATA one;
  SET one;
  z = INPUT(y, comma24.);
RUN;

However if I put the calculation of z in the first data step, I was getting missing values without any error message. I have no explanation for this behavior, but hopefully the workaround will work for you as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top