BookmarkSubscribeRSS Feed
Ravikumarkummari
Quartz | Level 8

Hi all,
can any one know the format for this
i have the dataset like this

product amount
account value
fixed 1,52,132
variable 2,50,478
annual rate
product 4.5%
variable 5.6%
this over all is one dataset.
i have read this data from excel using libname statement.
and the variable amount is in character type.
now i have to convert the data i.e. amount into numeric.
can any one know the process please comment.

4 REPLIES 4
ballardw
Super User

Is all of this in one column (variable) in the SAS data set? If so this is likely to be a mess. SAS can only have one characteristic per variable, either numeric or character. So you will have to create new variables using a data step. You may need to provide a bit more data for input example AND an example of what the output should look like.

It looks like you actually have 3 values for the rows that start with Fixed and Variable, is that the actual case? or did we lose something in pasting into the forum?

Kurt_Bremser
Super User

Read the column into a char variable, then check that variable for its layout and select the proper conversion.

It would be nice if you could provide an example of the data in csv form, so that we can determine the actual positioning of the data in the cells.

(ie is "product amount" in one or 2 cells?)

Ksharp
Super User
data have;
input p $ a : $20.;
cards;
fixed 1,52,132
variable 2,50,478
product 4.5%
variable 5.6%
;
run;
data want;
 set have;
 length fmt $ 20;
 if findc(a,',') then fmt='comma32.';
  else if findc(a,'%') then fmt='percent12.';
   else fmt='best32.';
 v=inputn(a,fmt);
 run;

Xia Keshan

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1570 views
  • 0 likes
  • 5 in conversation