BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
user1942
Fluorite | Level 6

Hello experts, I'm trying to make a data table and my values for RtlCost should have a dollar sign included, but it doesn't. I have tried using the dollar format but that adds another column labelled as format to my table, which i don't want. Please help! Here is my code:

 

data problem3;
input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost comma7.0;
cards;
5009 Dream Machine          500 Workstation $3,200
4506 Business Machine       450 Workstation $3,345
2101 Travel Laptop         400 Laptop     $2,760
2212 Analog Cell Phone      230 Phone     $35
4509 Digital Cell Phone     245 Phone     $175
5003 Office Phone         560 Phone     $145
1110 Spreadsheet Software   134 Software $300
1200 Database Software     113 Software $799
3409 Statistical Software   243 Software $1,899
2102 Wordprocessor Software 245 Software $345
2200 Graphics Software     246 Software $599
;
proc print data=problem3;
run;
proc sql;
insert into problem3
values(3480, 'Desktop Computer', 780, 'Workstation', 1799);
select * 
from problem3;
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11
data problem3;
format RtlCost dollar8.0;
input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;

put (_all_) (=);
cards;
5009 Dream Machine          500 Workstation $3,200
4506 Business Machine       450 Workstation $3,345
2101 Travel Laptop          400 Laptop      $2,760
2212 Analog Cell Phone      230 Phone       $35
4509 Digital Cell Phone     245 Phone       $175
5003 Office Phone           560 Phone       $145
1110 Spreadsheet Software   134 Software    $300
1200 Database Software      113 Software    $799
3409 Statistical Software   243 Software    $1,899
2102 Wordprocessor Software 245 Software    $345
2200 Graphics Software      246 Software    $599
;
run;

 

Log :

 

26         data problem3;
27         format RtlCost dollar8.0;
28         input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;
29         
30         put (_all_) (=);
31         cards;

RtlCost=$3,200 ProdNum=5009 ProdName=Dream Machine ManuNum=500 PodType=Workstation
RtlCost=$3,345 ProdNum=4506 ProdName=Business Machine ManuNum=450 PodType=Workstation
RtlCost=$2,760 ProdNum=2101 ProdName=Travel Laptop ManuNum=400 PodType=Laptop
RtlCost=$35 ProdNum=2212 ProdName=Analog Cell Phone ManuNum=230 PodType=Phone
RtlCost=$175 ProdNum=4509 ProdName=Digital Cell Phone ManuNum=245 PodType=Phone
RtlCost=$145 ProdNum=5003 ProdName=Office Phone ManuNum=560 PodType=Phone
RtlCost=$300 ProdNum=1110 ProdName=Spreadsheet Software ManuNum=134 PodType=Software
RtlCost=$799 ProdNum=1200 ProdName=Database Software ManuNum=113 PodType=Software
RtlCost=$1,899 ProdNum=3409 ProdName=Statistical Software ManuNum=243 PodType=Software
RtlCost=$345 ProdNum=2102 ProdName=Wordprocessor Software ManuNum=245 PodType=Software
RtlCost=$599 ProdNum=2200 ProdName=Graphics Software ManuNum=246 PodType=Software
NOTE: The data set WORK.PROBLEM3 has 11 observations and 5 variables.
NOTE: Compressing data set WORK.PROBLEM3 increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.

View solution in original post

3 REPLIES 3
r_behata
Barite | Level 11
data problem3;
format RtlCost dollar8.0;
input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;

put (_all_) (=);
cards;
5009 Dream Machine          500 Workstation $3,200
4506 Business Machine       450 Workstation $3,345
2101 Travel Laptop          400 Laptop      $2,760
2212 Analog Cell Phone      230 Phone       $35
4509 Digital Cell Phone     245 Phone       $175
5003 Office Phone           560 Phone       $145
1110 Spreadsheet Software   134 Software    $300
1200 Database Software      113 Software    $799
3409 Statistical Software   243 Software    $1,899
2102 Wordprocessor Software 245 Software    $345
2200 Graphics Software      246 Software    $599
;
run;

 

Log :

 

26         data problem3;
27         format RtlCost dollar8.0;
28         input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;
29         
30         put (_all_) (=);
31         cards;

RtlCost=$3,200 ProdNum=5009 ProdName=Dream Machine ManuNum=500 PodType=Workstation
RtlCost=$3,345 ProdNum=4506 ProdName=Business Machine ManuNum=450 PodType=Workstation
RtlCost=$2,760 ProdNum=2101 ProdName=Travel Laptop ManuNum=400 PodType=Laptop
RtlCost=$35 ProdNum=2212 ProdName=Analog Cell Phone ManuNum=230 PodType=Phone
RtlCost=$175 ProdNum=4509 ProdName=Digital Cell Phone ManuNum=245 PodType=Phone
RtlCost=$145 ProdNum=5003 ProdName=Office Phone ManuNum=560 PodType=Phone
RtlCost=$300 ProdNum=1110 ProdName=Spreadsheet Software ManuNum=134 PodType=Software
RtlCost=$799 ProdNum=1200 ProdName=Database Software ManuNum=113 PodType=Software
RtlCost=$1,899 ProdNum=3409 ProdName=Statistical Software ManuNum=243 PodType=Software
RtlCost=$345 ProdNum=2102 ProdName=Wordprocessor Software ManuNum=245 PodType=Software
RtlCost=$599 ProdNum=2200 ProdName=Graphics Software ManuNum=246 PodType=Software
NOTE: The data set WORK.PROBLEM3 has 11 observations and 5 variables.
NOTE: Compressing data set WORK.PROBLEM3 increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
Tom
Super User Tom
Super User

If you want your values displayed in a special way then tell that to SAS by attaching a format to the varaible.

The built in DOLLAR format will display numbers with a $ prefix and thousands separators.

If that is not what you want then build your own format using PROC FORMAT.

ballardw
Super User

@user1942 wrote:

Hello experts, I'm trying to make a data table and my values for RtlCost should have a dollar sign included, but it doesn't. I have tried using the dollar format but that adds another column labelled as format to my table, which i don't want. Please help! Here is my code:

 


Probably means that you had a syntax problem. Show us the code with the messages from the log that did that.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 474 views
  • 0 likes
  • 4 in conversation