🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It finally worked with the addition of the date02=strip(date02); statement. Thanks to both you and @art297. I really appreciate both of your help with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much. I will definitely try that. Appreciate your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I just tried and I got an error message with the "then". Please find the message from the log below:
123 data diagfix1;
124 set disease;
125 len = length(strip(date02));
126 select (len);
127 when (4) then diagdate = mdy(01,01,input(date02,4.));
----
180
128 when (7) then diagdate = input('01'||date02, date9.);
----
180
129 when (9) then diagdate = input(date02,date9.);
----
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
130 otherwise put 'Check obs ' _N_ date02=;
131 end;
132 diagtime=intck('year',diagdate,daterand);
133 run;
NOTE: The SAS System stopped processing this step because of errors.
Thanks.
123 data diagfix1;
124 set disease;
125 len = length(strip(date02));
126 select (len);
127 when (4) then diagdate = mdy(01,01,input(date02,4.));
----
180
128 when (7) then diagdate = input('01'||date02, date9.);
----
180
129 when (9) then diagdate = input(date02,date9.);
----
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
130 otherwise put 'Check obs ' _N_ date02=;
131 end;
132 diagtime=intck('year',diagdate,daterand);
133 run;
NOTE: The SAS System stopped processing this step because of errors.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, my bug.
Drop the 'then' - code should be:
len = length(strip(date_var));
select (len);
when (4) date = mdy(01,01,input(date_var,4.));
when (7) date = input('01'||date_var, date9.);
when (9) date = input(date_var,date9.);
otherwise put 'Check obs ' _N_ date_var=;
end;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want to output 3 files, then the following should work:
data year mmyyyy mdy;
set have;
select (length(strip(diagdate)));
when (7) output mmyyyy;
when (9) output mdy;
otherwise output year;
end;
run;
HTH,
Art, CEO, AnalystFinder.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@PaulaC: Sorry to hear that you're still having problems. Seeing your code would definitely help as well as seeing the dates (as entered in the raw data) for the 50 people in question.
The following definitely worked for me given your sample data:
data year mmyyyy mdy;
input date02 $9.;
format diagdate date9.;
select (length(strip(date02)));
when (4) do;
diagdate = mdy(01,01,input(date02,4.));
output year;
end;
when (7) do;
diagdate = input('01'||date02, date9.);
output mmyyyy;
end;
when (9) do;
diagdate = input(date02,date9.);
output mdy;
end;
otherwise put 'Check obs ' _N_ date02=;
end;
cards;
1963
1964
1970
1972
198
1980
1981
APR1993
DEC1991
FEB1995
JUL1980
MAR1993
MAY1995
NOV1973
NOV1994
OCT1979
01APR1993
01APR1997
01AUG1991
;
Art, CEO, AnalystFinder.com
- « Previous
-
- 1
- 2
- Next »