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

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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