BookmarkSubscribeRSS Feed
Mohammed
Calcite | Level 5
SupplierCityItem CategoryMonthCostRevenueUnit PriceUnits AvailableUnits Sold
Bantam BooksAnnapolisArt & ArchitectureJan$38,136$47,760$105.00655454
Bantam BooksAnnapolisArt & ArchitectureFeb$11,919$56,785$54.00429388
Bantam BooksAnnapolisArt & ArchitectureMar$1,24,897$98,586`$98.008945

Hi All,

I have an excel csv file, which has 9 variables and some 24 observations for each variable. The variables are in order they appear:

1. Supplier

2. City

3. Item Category

4. Month

5. Cost

6. Revenue

7. Unit Price

8. Units Available

9. Units Sold.

The only confusion is:  Cost and Revenue has $ associated with it ($38,000 for example) and Unit Price as $105.00 . Not sure, how do I convert this to Numeric format.

So, I wrote a code for this as:

data get_data;

infile " file location of the excel where it is located";

Length Supplier $20. City $20.  Item Category $20.;

Input Supplier $ City $ Item Category $ Month $ Cost $ Revenue $ Unit Price $ Units Available Units Sold;

numeric=input(Cost, 8.);

numeric=input(Revenue, 10.);

numeric=input(Unit Price, 8.);

proc print;

run;

It gives an error for this code and the values are not read properly into SAS . It says no result to display.

Please assist me in writing the right code.

Regards,

Mohammed

Please assist

1 REPLY 1
Reeza
Super User

Don't use a character informat in the first place? Remove the $ sign, I would also use the DSD option and Truncover on my infile statement.

data get_data;

Length Supplier $20. City $20.  Item Category $20.;

format cost revenue unit_price dollar12.;

informat cost revenue unit_price dollar12.;

infile " file location of the excel where it is located" DSD truncover;

Input Supplier $ City $ Item Category $ Month $ Cost Revenue  Unit_Price  Units_Available Units_Sold;

run;

proc print;

run;

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
  • 1 reply
  • 583 views
  • 0 likes
  • 2 in conversation