Hello Friends
I have code like this below: When I tried to run I get an error. Can you please tell me whether is there issue with this code?
data test3;
input name $ age salary informat comma9.;
datalines;
john 35 $3,500.00
Jodi 43 $2,850.00
Noel 45 $4,200.00
;
run;
Thanks you very much
From now on, please don't tell us there's an error, and then not tell us what the error is. When there is an error, show us the log or show us (and explain) the incorrect output.
I think you want this:
data test3;
input name $ age salary comma9.;
datalines;
john 35 $3,500.00
Jodi 43 $2,850.00
Noel 45 $4,200.00
;
From now on, please don't tell us there's an error, and then not tell us what the error is. When there is an error, show us the log or show us (and explain) the incorrect output.
I think you want this:
data test3;
input name $ age salary comma9.;
datalines;
john 35 $3,500.00
Jodi 43 $2,850.00
Noel 45 $4,200.00
;
Thanks Miller. This is the log when I run the query.
108 data test3;
109 input name $ age salary informat comma9.;
110 datalines;
NOTE: Invalid data for salary in line 112 9-17.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----
112 john 35 $3,500.00
name=john age=35 salary=. informat=. _ERROR_=1 _N_=1
NOTE: Invalid data for salary in line 113 9-17.
113 Jodi 43 $2,850.00
name=Jodi age=43 salary=. informat=. _ERROR_=1 _N_=2
NOTE: Invalid data for salary in line 114 9-17.
114 Noel 45 $4,200.00
name=Noel age=45 salary=. informat=. _ERROR_=1 _N_=3
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.TEST3 has 3 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
115 ;
116 run;
Thanks it is working as per your code below:
data test3;
input name $ age salary comma9.;
datalines;
john 35 $3,500.00
Jodi 43 $2,850.00
Noel 45 $4,200.00
;
run;
proc print data=test3;
informat salary comma9.;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.