BookmarkSubscribeRSS Feed
Koke
Fluorite | Level 6

Hi, guys

I'm struggling in print my new value (Mileage, Cost), but unfortunately it still did not work even I used commax and dollarx.

The result is (.), and I'm not sure what I'm missing. I use sas university edition.

Need help

data usedcar;
infile "/folders/myshortcuts/SASUniversityEdition/module 3/usedcars.txt"
firstobs=2 expandtabs obs=50 dsd
;
input
Year $2. Manufacturer $16. Model $16. Mileage commax. cost dollarx.
;
proc
contents data = usedcar varnum;
Proc
Format;
value Mileage low - 50000 = '<50,000'
50000 - high = '>=50,000'
other = 'Unknown';

Value Cost low - 5000 = 'Economic'
5000-10000 = 'Moderate'
other = 'Expensive';
Proc
print;
run;

 Here is my log

 
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data usedcar;
63 infile "/folders/myshortcuts/SASUniversityEdition/module 3/usedcars.txt"
64 firstobs=2 expandtabs obs=50 dsd
65 ;
66 input
67 Year $2. Manufacturer $16. Model $16. Mileage commax. cost dollarx.
68 ;
 
NOTE: The infile "/folders/myshortcuts/SASUniversityEdition/module 3/usedcars.txt" is:
(no system-specific pathname available),
(no system-specific file attributes available)
 
NOTE: 49 records were read from the infile "/folders/myshortcuts/SASUniversityEdition/module 3/usedcars.txt".
The minimum record length was 91.
The maximum record length was 91.
NOTE: The data set WORK.USEDCAR has 49 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.02 seconds
 
69 proc
70 contents data = usedcar varnum;
 
 
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.51 seconds
cpu time 0.46 seconds
 
71 Proc
72 Format;
 
73 value Mileage low - 50000 = '<50,000'
74 50000 - high = '>=50,000'
75 other = 'Unknown';
NOTE: Format MILEAGE is already on the library WORK.FORMATS.
NOTE: Format MILEAGE has been output.
76
77 Value Cost low - 5000 = 'Economic'
78 5000-10000 = 'Moderate'
79 other = 'Expensive';
NOTE: Format COST is already on the library WORK.FORMATS.
NOTE: Format COST has been output.
 
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
80 Proc
81 print;
 
82 run;
 
NOTE: There were 49 observations read from the data set WORK.USEDCAR.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.50 seconds
cpu time 0.49 seconds
 
82 !
 
83
84
85 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
98
 
xxxxxxxxxxxxxxxxx Here is my data (Example) xxxxxxxxxxxxxxxxx

94 Chrysler LeBaron 50,000 $7,999 
2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

You have defined the format but not used it.

You can for example add a format statement to the proc print.

art297
Opal | Level 21

Your first datastep won't run as expected, Some of your infile options are throwing off the results and some of your informats are wrong. I think that you'll find the following to work a lot better:

data usedcar;
 infile "/folders/myshortcuts/SASUniversityEdition/module 3/usedcars.txt"
    firstobs=2 obs=50 ;
 informat year $2.;
 informat Manufacturer $16.;
 informat Model $16.;
 informat Mileage comma10.;
 informat cost dollar7.;
 input Year Manufacturer Model  Mileage cost;
run;

Art, CEO, AnalystFinder.com

 

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!

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