DATA Step, Macro, Functions and more

base sas

Reply
Contributor
Posts: 23

base sas


171 data ds;
172 infile datalines ;
173 input id 5. name&$20. age 3. sex$7. sal 5.;
174 datalines;

NOTE: Invalid data for sal in line 175 33-37.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
175 1002 sarvesh ranjani 30 male 32000
id=1002 name=sarvesh ranjani age=. sex=30 mal sal=. _ERROR_=1 _N_=1
NOTE: Invalid data for age in line 176 30-32.
176 1006 radhe govinda swamy 30 female 30000
id=1006 name=radhe govinda swamy age=. sex=ale 300 sal=0 _ERROR_=1 _N_=2
NOTE: Invalid data for age in line 177 30-32.
177 1047 yagna prajna shohel 52 male 32200
id=1047 name=yagna prajna shohel age=. sex=e 322 sal=0 _ERROR_=1 _N_=3
NOTE: Invalid data for sal in line 178 35-39.
178 1098 keerthana gowsami 32 female 12000
id=1098 name=keerthana gowsami age=32 sex=femal sal=. _ERROR_=1 _N_=4
NOTE: The data set WORK.DS has 4 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

Esteemed Advisor
Posts: 5,541

Re: base sas

Posted in reply to vinod4842
data ds;
length name $24;
input @;
if countw(_infile_) = 6 then 
    input id (_n1 _n2) (:$16.) age sex :$6. sal;
else
    input id (_n1 _n2 _n3) (:$16.) age sex :$6. sal;
name = catx(" ", of _n:);
drop _n: ;
datalines;
....
;
PG
Ask a Question
Discussion stats
  • 1 reply
  • 61 views
  • 1 like
  • 2 in conversation