Missing Dollar Values Far Right Side

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Missing Dollar Values Far Right Side

I was able to show all of the values except for the Total Sales column. I can show the value in thousands, but the values in hundred just won't show up. How do I fix the code? Thanks. Attached png file is the output of the code.


data bikes1;
infile "/folders/myfolders/austin.txt" dlm='09'x;
;
length
Country $14
Bike $13
Model $10
Units 4
Price 6
TotalSales 7
;
format Price dollar6. TotalSales dollar7.;
input Country Bike Model Units Price dollar6. TotalSales dollar9.;
run;

proc print data=bikes1 noobs;
run;

*
USA Road Bike Trek 5000 $2,200 $11,000
USA Hybrid Trek 4500 $650 $2,925
USA Road Bike Cannondale 2000 $2,100 $4,200
USA Mountain Bike Trek 6000 $1,200 $7,200
USA Mountain Bike Cannondale 4000 $2,700 $10,800
United Kingdom Hybrid Cannondale 500 $880 $440
United Kingdom Hybrid Trek 800 $490 $392
United Kingdom Road Bike Cannondale 1200 $2,123 $2,548
United Kingdom Road Bike Trek 2444 $2,100 $5,132
United Kingdom Mountain Bike Trek 1211 $1,121 $1,358
Italy Mountain Bike Trek 3400 $1,877 $6,382
Italy Road Bike Trek 4500 $2,890 $13,005
Italy Hybrid Trek 700 $690 $483
France Road Bike Cannondale 900 $3,700 $3,330
France Road Bike Trek 3400 $2,500 $8,500
France Hybrid Trek 1100 $540 $594
France Mountain Bike Cannondale 800 $1,899 $1,519
France Mountain Bike Trek 5600 $1,300 $7,280
;

 

 

Attachment

Accepted Solutions
Solution
‎09-15-2016 11:29 AM
Regular Contributor
Posts: 236

Re: Missing Dollar Values Far Right Side

data bikes1;
infile "/folders/myfolders/austin.txt" dlm='09'x;
;
length
Country $14
Bike $13
Model $10
Units 4
Price 6
TotalSales 7
;
informat Price dollar6. TotalSales dollar7.;
input Country Bike Model Units Price TotalSales ;
run;
proc print data=bikes1 noobs;
run;

Made two changes

1. format changed to informat

2. input statement I removed all the format.

View solution in original post


All Replies
Esteemed Advisor
Esteemed Advisor
Posts: 7,249

Re: Missing Dollar Values Far Right Side

There are various things wrong with the read in.  This code will read in the data correctly:

data bikes1;
  infile datalines dlm="|";
  length  country $14
          bike $13
          model $10
          units 4
          price 6
          totalsales 7;
  format price dollar6. totalSales dollar9.;
  informat price dollar6. totalsales dollar9.;
  input country bike model units price totalsales;
datalines;
USA|Mountain Bike|Cannondale|4000|$2,700|$10,800
United Kingdom|Hybrid|Cannondale|500|$880|$440
;
run;
Super Contributor
Posts: 305

Re: Missing Dollar Values Far Right Side

hello,

 

you shall check the import step and look at the log.

 

if your data is organised well in the *.txt file the import shall work.

 

by the way better use modified list input rather than length statement.

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm

Solution
‎09-15-2016 11:29 AM
Regular Contributor
Posts: 236

Re: Missing Dollar Values Far Right Side

data bikes1;
infile "/folders/myfolders/austin.txt" dlm='09'x;
;
length
Country $14
Bike $13
Model $10
Units 4
Price 6
TotalSales 7
;
informat Price dollar6. TotalSales dollar7.;
input Country Bike Model Units Price TotalSales ;
run;
proc print data=bikes1 noobs;
run;

Made two changes

1. format changed to informat

2. input statement I removed all the format.

Occasional Contributor
Posts: 7

Re: Missing Dollar Values Far Right Side

Thanks a lot. Then, I added another line of code to put the $ format back in.

 


data bikes1;
infile "/folders/myfolders/austin.txt" dlm='09'x;
;
length
Country $14
Bike $13
Model $10
Units 4
Price 6
TotalSales 7
;
informat Price dollar6. TotalSales dollar7.;
format Price dollar6. TotalSales dollar7.;
input Country Bike Model Units Price TotalSales;
run;

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 317 views
  • 1 like
  • 4 in conversation