The code below includes my code to program the new variables and the dataset along with the log that shows the errors of not being able to find the proper numeric variables. Doors only appear as a value of 1 when they should be taking on a value of 0 at times, and AVGMPG isn't appearing at all.
options MSGLEVEL=I;
libname Ec351 "/home/u59307513/Ec351";
proc import datafile='/home/u59307513/Ec351/CarPrice Regression Dataset Ec351.xls' dbms=xls out=EC351.Project1 replace;
getnames=yes;
run;
data ec351.projectsorted;
set ec351.project1;
options validvarname=any;
if year < 2017 then delete;
run;
data ec351.projectuseabledata ;
set ec351.projectsorted;
if "Transmission Type"n = 'MANUAL' then Trans = 0;
else Trans = 1 ;
if 'Number_of_doors' = 2 then doors = 0;
else doors = 1;
drop year;
AvgMPG = (('City_MPG'+'Highway_MPG')/2);
run;
proc print data= ec351.projectuseabledata;
run;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
INFO: Character variables have defaulted to a length of 200 at the places given by: (Line):(Column). Truncation can result.
38:1 RC
68
69 options MSGLEVEL=I;
70 libname Ec351 "/home/u59307513/Ec351";
NOTE: Libref EC351 was successfully assigned as follows:
Engine: V9
Physical Name: /home/u59307513/Ec351
71 proc import datafile='/home/u59307513/Ec351/CarPrice Regression Dataset Ec351.xls' dbms=xls out=EC351.Project1 replace;
72 getnames=yes;
73 run;
NOTE: VARCHAR data type is not supported by the V9 engine. Variable Transmission Type has been converted to CHAR data type.
NOTE: The import data set has 11914 observations and 7 variables.
NOTE: EC351.PROJECT1 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.04 seconds
user cpu time 0.02 seconds
system cpu time 0.00 seconds
memory 3242.59k
OS Memory 36836.00k
Timestamp 12/05/2022 09:05:57 PM
Step Count 685 Switch Count 2
Page Faults 0
Page Reclaims 669
Page Swaps 0
Voluntary Context Switches 53
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 1544
74
75
76 data ec351.projectsorted;
77 set ec351.project1;
78 options validvarname=any;
79 if year < 2017 then delete;
80 run;
NOTE: There were 11914 observations read from the data set EC351.PROJECT1.
NOTE: The data set EC351.PROJECTSORTED has 1668 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1604.28k
OS Memory 35252.00k
Timestamp 12/05/2022 09:05:57 PM
Step Count 686 Switch Count 2
Page Faults 0
Page Reclaims 257
Page Swaps 0
Voluntary Context Switches 64
Involuntary Context Switches 0
Block Input Operations 1568
Block Output Operations 264
81
82 data ec351.projectuseabledata ;
83 set ec351.projectsorted;
84 if "Transmission Type"n = 'MANUAL' then Trans = 0;
85 else Trans = 1 ;
86 if 'Number_of_doors' = 2 then doors = 0;
87 else doors = 1;
88 drop year;
89 AvgMPG = (('City_MPG'+'Highway_MPG')/2);
90 run;
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
86:4 89:12 89:23
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=160 Transmission Type=MANUAL Number of Doors=2 highway MPG=35 city mpg=26 MSRP=27495 Trans=0 doors=1 AvgMPG=.
_ERROR_=1 _N_=1
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=160 Transmission Type=MANUAL Number of Doors=2 highway MPG=35 city mpg=26 MSRP=24995 Trans=0 doors=1 AvgMPG=.
_ERROR_=1 _N_=2
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=160 Transmission Type=MANUAL Number of Doors=2 highway MPG=35 city mpg=26 MSRP=28195 Trans=0 doors=1 AvgMPG=.
_ERROR_=1 _N_=3
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=335 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=31 city mpg=21 MSRP=46450 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=4
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=335 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=32 city mpg=21 MSRP=49050 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=5
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=335 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=32 city mpg=21 MSRP=51050 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=6
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=335 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=32 city mpg=21 MSRP=44450 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=7
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=248 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=34 city mpg=23 MSRP=38950 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=8
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=248 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=35 city mpg=24 MSRP=33150 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=9
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=248 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=33 city mpg=24 MSRP=35150 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=10
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=248 Transmission Type=AUTOMATIC Number of Doors=2 highway MPG=33 city mpg=23 MSRP=40950 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=11
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=295 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=28 city mpg=18 MSRP=29905 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=12
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=295 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=28 city mpg=18 MSRP=31785 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=13
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=184 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=36 city mpg=23 MSRP=26685 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=14
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=184 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=36 city mpg=23 MSRP=22490 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=15
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=184 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=36 city mpg=23 MSRP=25690 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=16
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=295 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=28 city mpg=18 MSRP=30900 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=17
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=184 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=36 city mpg=23 MSRP=27795 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=18
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
Year=2017 Engine HP=184 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=36 city mpg=23 MSRP=21995 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=19
NOTE: Invalid numeric data, 'Number_of_doors' , at line 86 column 4.
NOTE: Invalid numeric data, 'City_MPG' , at line 89 column 12.
NOTE: Invalid numeric data, 'Highway_MPG' , at line 89 column 23.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
Year=2017 Engine HP=184 Transmission Type=AUTOMATIC Number of Doors=4 highway MPG=36 city mpg=23 MSRP=24490 Trans=1 doors=1 AvgMPG=.
_ERROR_=1 _N_=20
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
1668 at 89:22
NOTE: There were 1668 observations read from the data set EC351.PROJECTSORTED.
NOTE: The data set EC351.PROJECTUSEABLEDATA has 1668 observations and 9 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1285.50k
OS Memory 34740.00k
Timestamp 12/05/2022 09:05:57 PM
Step Count 687 Switch Count 1
Page Faults 0
Page Reclaims 98
Page Swaps 0
Voluntary Context Switches 51
Involuntary Context Switches 0
Block Input Operations 288
Block Output Operations 536
91
92 proc print data= ec351.projectuseabledata;
93 run;
NOTE: There were 1668 observations read from the data set EC351.PROJECTUSEABLEDATA.
NOTE: PROCEDURE PRINT used (Total process time):
real time 2.53 seconds
user cpu time 2.53 seconds
system cpu time 0.00 seconds
memory 1473.31k
OS Memory 34480.00k
Timestamp 12/05/2022 09:06:00 PM
Step Count 688 Switch Count 0
Page Faults 0
Page Reclaims 80
Page Swaps 0
Voluntary Context Switches 12
Involuntary Context Switches 3
Block Input Operations 544
Block Output Operations 1000
94
95
96
97 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
107
When you posted this question yesterday, you received several good answers including one that you selected as the solution. So what is happening? Did you accidentally post again? Did you not understand the suggested solutions?
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!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.