i'm failing to understand the do while(1) construct, 1 in () does it mean anything in the expression without referencing a variable name in the do while(expression)
data w ( keep = date time cond species vers hdr x1 - x9 ) ;
format date date7. time time12.2 ;
infile cards truncover eof = fini ;
input @'date ' datec $char9.
@'time ' time :time11.
/ @'Condition: ' cond $char20.
/ @'Species: ' species $8.
/ @'version: ' vers $8.
/ @'information: ' hdr $20.
/ ;
/* will the software produce bad dates in 2+ years??? */
date = input ( compress ( datec,'-'), date7. ) ;
do while ( 1 ) ; /* what does this expression mean?*/
input ( x1 - x9 ) ( :$20. ) ;
output ;
end ;
return ;
fini:
return ;
cards ;
date 10-jan-95 time 05:20.36.44
Condition: blah, blah, blah,
Species: 4LA
Software version: xxx.xx
Other header information: aaaa.a bbbbb.b
operators-who-collected-the-data...
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
;
The expression evaluated is 1, TRUE. It means do forever. The thing you need to know is why doesn't it actually do forever. For that look at INFILE statement options EOF= and UNBUFFERED.
The do while(1) will simply keep reading and outputting your x1-x9 values until it reaches an end of file. It is simply saying do while(true)
Yes, you will run into problems if your date ever contains a 4 digit year.
And, if your times are really in the format shown in your example, they will have to be modified before input as well.
e.g.,
data w ( keep = date time cond species vers hdr x1 - x9 ) ;
informat datec $char11.;
informat timec $char11.;
format date date7.;
format time time12.2 ;
infile cards truncover eof = fini ;
input @'date ' datec
@'time ' timec
/ @'Condition: ' cond $char20.
/ @'Species: ' species $8.
/ @'version: ' vers $8.
/ @'information: ' hdr $20.
/ ;
/* will the software produce bad dates in 2+ years??? */
date = input ( compress ( datec,'-'), anydtdte9. ) ;
substr(timec,index(timec,'.'),1) = ':';
time=input(timec,time11.);
do while ( 1 ) ; /* what does this expression mean?*/
input ( x1 - x9 ) ( :$20. ) ;
output ;
end ;
return ;
fini:
return ;
cards ;
date 10-jan-2014 time 05:20.36.44
Condition: blah, blah, blah,
Species: 4LA
Software version: xxx.xx
Other header information: aaaa.a bbbbb.b
operators-who-collected-the-data...
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
x y x az el ra speed direction, etc.
;
cool. Thanks Art and DN. Is there any specific document or link can you point me to for more and complete information on such do loop constructs particularly mentioning different ways to write expressions to use in do loop constructs unlike the convention as well as like using set inside a do loop, do _n_= as index variable and so on ? I have read through some on some docs found online but my grasping to this kind isn't quick:( Sorry for the bother
Mark
Mark: Post an example of the data you are trying to read and it will be a lot easier to point you in the right direction.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: