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
You have defined the format but not used it.
You can for example add a format statement to the proc print.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.