BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ak2011
Fluorite | Level 6

Hi,

Happy new year.

I would appreciate if someone helps me with the SAS code to read the following 29 records correctly.

The code I used resulted in error. 

 

/* Dataset 3: Exposure to pollutants records*/
data env;
input id$ job idchem lung$;
datalines;
OSa06 3210701 Ca cont
OSa13 1 210701 Ca case
OSa13 1 990021 Ca case
OSa13 3 210701 Ca case
OSa13 3 990005 Ca case
OSa13 3 990021 Ca case
OSa29 2 990005 Ca cont
OSa29 4 210701 Ca cont
OSa29 4 990021 Ca cont
OSa30 1 990021 Ca case
OSa30 3 210701 Ca case
OSa30 3 990005 Ca case
OSa30 3 990021 Ca case
OSa54 3 210701 Pop cont
OSa73 3 990005 Pop cont
OSa86 3 990005 Ca cont
OSa93 3 210701 Pop cont
OSa93 3 990005 Pop cont
OSa93 4 990005 Pop cont
OSb12 1 210701 Ca cont
OSb16 1 990021 Ca case
OSb20 4 990005 Ca case
OSb38 3 210701 Ca cont
OSb38 3 990021 Ca cont
OSb58 1 210701 Pop cont
OSb70 1 990021 Ca cont
OSb70 2 990021 Ca cont
OSb70 3 990021 Ca cont
OSb70 4 990021 Ca cont
;

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data env;
74 input id$ job idchem lung;
75 datalines;
 
NOTE: Invalid data for idchem in line 76 16-17.
NOTE: Invalid data for lung in line 76 19-22.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
76 OSa06 3210701 Ca cont
id=OSa06 job=3210701 idchem=. lung=. _ERROR_=1 _N_=1
NOTE: Invalid data for job in line 77 7-14.
NOTE: Invalid data for idchem in line 77 16-17.
NOTE: Invalid data for lung in line 77 19-22.
 
77 CHAR OSa13 1.210701 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3113019210701031031350000000000000000000000000000000000000000000000000000000000
id=OSa13 job=. idchem=. lung=. _ERROR_=1 _N_=2
NOTE: Invalid data for job in line 78 7-14.
NOTE: Invalid data for idchem in line 78 16-17.
NOTE: Invalid data for lung in line 78 19-22.
 
78 CHAR OSa13 1.990021 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3113019990021031031350000000000000000000000000000000000000000000000000000000000
id=OSa13 job=. idchem=. lung=. _ERROR_=1 _N_=3
NOTE: Invalid data for job in line 79 7-14.
NOTE: Invalid data for idchem in line 79 16-17.
NOTE: Invalid data for lung in line 79 19-22.
 
79 CHAR OSa13 3.210701 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3113039210701031031350000000000000000000000000000000000000000000000000000000000
id=OSa13 job=. idchem=. lung=. _ERROR_=1 _N_=4
NOTE: Invalid data for job in line 80 7-14.
NOTE: Invalid data for idchem in line 80 16-17.
NOTE: Invalid data for lung in line 80 19-22.
 
80 CHAR OSa13 3.990005 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3113039990005031031350000000000000000000000000000000000000000000000000000000000
id=OSa13 job=. idchem=. lung=. _ERROR_=1 _N_=5
NOTE: Invalid data for job in line 81 7-14.
NOTE: Invalid data for idchem in line 81 16-17.
NOTE: Invalid data for lung in line 81 19-22.
 
81 CHAR OSa13 3.990021 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3113039990021031031350000000000000000000000000000000000000000000000000000000000
id=OSa13 job=. idchem=. lung=. _ERROR_=1 _N_=6
NOTE: Invalid data for job in line 82 7-14.
NOTE: Invalid data for idchem in line 82 16-17.
NOTE: Invalid data for lung in line 82 19-22.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
82 CHAR OSa29 2.990005 Ca cont
ZONE 45633230333333246266672222222222222222222222222222222222222222222222222222222222
NUMR F312902999000503103FE40000000000000000000000000000000000000000000000000000000000
id=OSa29 job=. idchem=. lung=. _ERROR_=1 _N_=7
NOTE: Invalid data for job in line 83 7-14.
NOTE: Invalid data for idchem in line 83 16-17.
NOTE: Invalid data for lung in line 83 19-22.
 
83 CHAR OSa29 4.210701 Ca cont
ZONE 45633230333333246266672222222222222222222222222222222222222222222222222222222222
NUMR F312904921070103103FE40000000000000000000000000000000000000000000000000000000000
id=OSa29 job=. idchem=. lung=. _ERROR_=1 _N_=8
NOTE: Invalid data for job in line 84 7-14.
NOTE: Invalid data for idchem in line 84 16-17.
NOTE: Invalid data for lung in line 84 19-22.
 
84 CHAR OSa29 4.990021 Ca cont
ZONE 45633230333333246266672222222222222222222222222222222222222222222222222222222222
NUMR F312904999002103103FE40000000000000000000000000000000000000000000000000000000000
id=OSa29 job=. idchem=. lung=. _ERROR_=1 _N_=9
NOTE: Invalid data for job in line 85 7-14.
NOTE: Invalid data for idchem in line 85 16-17.
NOTE: Invalid data for lung in line 85 19-22.
 
85 CHAR OSa30 1.990021 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3130019990021031031350000000000000000000000000000000000000000000000000000000000
id=OSa30 job=. idchem=. lung=. _ERROR_=1 _N_=10
NOTE: Invalid data for job in line 86 7-14.
NOTE: Invalid data for idchem in line 86 16-17.
NOTE: Invalid data for lung in line 86 19-22.
 
86 CHAR OSa30 3.210701 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3130039210701031031350000000000000000000000000000000000000000000000000000000000
id=OSa30 job=. idchem=. lung=. _ERROR_=1 _N_=11
NOTE: Invalid data for job in line 87 7-14.
NOTE: Invalid data for idchem in line 87 16-17.
NOTE: Invalid data for lung in line 87 19-22.
 
87 CHAR OSa30 3.990005 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3130039990005031031350000000000000000000000000000000000000000000000000000000000
id=OSa30 job=. idchem=. lung=. _ERROR_=1 _N_=12
NOTE: Invalid data for job in line 88 7-14.
NOTE: Invalid data for idchem in line 88 16-17.
NOTE: Invalid data for lung in line 88 19-22.
 
88 CHAR OSa30 3.990021 Ca case
ZONE 45633230333333246266762222222222222222222222222222222222222222222222222222222222
NUMR F3130039990021031031350000000000000000000000000000000000000000000000000000000000
id=OSa30 job=. idchem=. lung=. _ERROR_=1 _N_=13
NOTE: Invalid data for job in line 89 7-14.
NOTE: Invalid data for idchem in line 89 16-18.
NOTE: Invalid data for lung in line 89 20-23.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
89 CHAR OSa54 3.210701 Pop cont
ZONE 45633230333333256726667222222222222222222222222222222222222222222222222222222222
NUMR F315403921070100F003FE4000000000000000000000000000000000000000000000000000000000
id=OSa54 job=. idchem=. lung=. _ERROR_=1 _N_=14
NOTE: Invalid data for job in line 90 7-14.
NOTE: Invalid data for idchem in line 90 16-18.
NOTE: Invalid data for lung in line 90 20-23.
 
90 CHAR OSa73 3.990005 Pop cont
ZONE 45633230333333256726667222222222222222222222222222222222222222222222222222222222
NUMR F317303999000500F003FE4000000000000000000000000000000000000000000000000000000000
id=OSa73 job=. idchem=. lung=. _ERROR_=1 _N_=15
NOTE: Invalid data for job in line 91 7-14.
NOTE: Invalid data for idchem in line 91 16-17.
NOTE: Invalid data for lung in line 91 19-22.
 
91 CHAR OSa86 3.990005 Ca cont
ZONE 45633230333333246266672222222222222222222222222222222222222222222222222222222222
NUMR F318603999000503103FE40000000000000000000000000000000000000000000000000000000000
id=OSa86 job=. idchem=. lung=. _ERROR_=1 _N_=16
NOTE: Invalid data for job in line 92 7-14.
NOTE: Invalid data for idchem in line 92 16-18.
NOTE: Invalid data for lung in line 92 20-23.
 
92 CHAR OSa93 3.210701 Pop cont
ZONE 45633230333333256726667222222222222222222222222222222222222222222222222222222222
NUMR F319303921070100F003FE4000000000000000000000000000000000000000000000000000000000
id=OSa93 job=. idchem=. lung=. _ERROR_=1 _N_=17
NOTE: Invalid data for job in line 93 7-14.
NOTE: Invalid data for idchem in line 93 16-18.
NOTE: Invalid data for lung in line 93 20-23.
 
93 CHAR OSa93 3.990005 Pop cont
ZONE 45633230333333256726667222222222222222222222222222222222222222222222222222222222
NUMR F319303999000500F003FE4000000000000000000000000000000000000000000000000000000000
id=OSa93 job=. idchem=. lung=. _ERROR_=1 _N_=18
NOTE: Invalid data for job in line 94 7-14.
NOTE: Invalid data for idchem in line 94 16-18.
NOTE: Invalid data for lung in line 94 20-23.
 
94 CHAR OSa93 4.990005 Pop cont
ZONE 45633230333333256726667222222222222222222222222222222222222222222222222222222222
NUMR F319304999000500F003FE4000000000000000000000000000000000000000000000000000000000
id=OSa93 job=. idchem=. lung=. _ERROR_=1 _N_=19
NOTE: Invalid data for job in line 95 7-14.
NOTE: Invalid data for idchem in line 95 16-17.
NOTE: Invalid data for lung in line 95 19-22.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
 
95 CHAR OSb12 1.210701 Ca cont
ZONE 45633230333333246266672222222222222222222222222222222222222222222222222222222222
NUMR F321201921070103103FE40000000000000000000000000000000000000000000000000000000000
id=OSb12 job=. idchem=. lung=. _ERROR_=1 _N_=20
NOTE: The data set WORK.ENV has 29 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds
 
 
105 ;
106
107
108 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
120
 
Thanks in advance.
ak.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @ak2011 

 

Two things:

 

  • I think the first data line is incorrect ->
OSa06  3210701 Ca cont

should be replaced by:

OSa06 3 210701 Ca cont
  • In addition, you can for example specify to SAS the column numbers to indicate where the variable values are found in the input data records.
input id$ 1-5 job 7 idchem lung$ 16-23;

 

You can refer to the following link for more options: https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n0oaql83drile0n141pdacojq97s.htm&doc... 

View solution in original post

7 REPLIES 7
WarrenKuhfeld
Rhodochrosite | Level 12

Check your data. Probably want a blank after the 3 in the first data line. Put $ after idchem

ed_sas_member
Meteorite | Level 14

Hi @ak2011 

 

Two things:

 

  • I think the first data line is incorrect ->
OSa06  3210701 Ca cont

should be replaced by:

OSa06 3 210701 Ca cont
  • In addition, you can for example specify to SAS the column numbers to indicate where the variable values are found in the input data records.
input id$ 1-5 job 7 idchem lung$ 16-23;

 

You can refer to the following link for more options: https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n0oaql83drile0n141pdacojq97s.htm&doc... 

ak2011
Fluorite | Level 6
Thanks. It works!
novinosrin
Tourmaline | Level 20

 

Hi @ak2011  Requesting you to mark @ed_sas_member  's  solution as answered and close the thread. Thank you!

ak2011
Fluorite | Level 6

Thanks very much for the response.

ak.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 791 views
  • 0 likes
  • 5 in conversation