BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sas_td2016
Obsidian | Level 7

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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
;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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
;
--
Paige Miller
sas_td2016
Obsidian | Level 7

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;

sas_td2016
Obsidian | Level 7

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 592 views
  • 0 likes
  • 2 in conversation