Hello.
I have a dataset that has a birthdate variable but in different form.
There are three types of birthdate value.
First one is 4 characters that represent year. (e.g. 1993)
Second one is 10 characters that represent mm-dd-yyyy. (e.g. 03-06-1965)
And the final one is missing value. (e.g. )
The birthdate variable is formatted as $10.
Now, I want to change the birthdate variable as date format.
Below is a code that I wrote to get what I want.
However, I got error message when I ran the code.
Could anybody give some ideas about this issye?
Thank you.
data birthdate;
set birthdate_raw;
if length(birthdate)=4 then birthdate=mdy(6,30,input(birthdate,4.));
else if length(birthdate)=10 then birthdate=input(birthdate,mmddyy10.);
else birthdate=.;
run;
In the mean time, I found what happend to my dataset.
There were few observations in the form of ddmmyy10. istead of mmddyy10.
I changed my code into like this
data man. manager_info_full_match_date_rv;
set man. manager_info_full_match;
if length(birthdate)=4 then n_birthdate=mdy(6,30,input(birthdate,4.));
else if length(birthdate)=9 and input(scan(birthdate,1,"/"),best2.)>12 then n_birthdate=input("0"||birthdate,ddmmyy10.);
else if length(birthdate)=9 and input(scan(birthdate,1,"/"),best2.)<=12 then n_birthdate=input("0"||birthdate,mmddyy10.);
else if length(birthdate)=10 and input(scan(birthdate,1,"/"),best2.)>12 then n_birthdate=input(birthdate,ddmmyy10.);
else if length(birthdate)=10 and input(scan(birthdate,1,"/"),best2.)<=12 then n_birthdate=input(birthdate,mmddyy10.);
else n_birthdate=.;
run;
Now, I got the result that I sought for.
Again, thanks for the reply.
What was the error you recieved?
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=F00000OLIT FundId=FS00009NRF CUSIP=00769G634 start_date=19235 end_date=20148 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37844
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA02STW FundId=FSUSA003E0 CUSIP=277911384 start_date=19114 end_date=20240 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37845
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00GH4 FundId=FSUSA003E0 CUSIP=277911723 start_date=19114 end_date=20240 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37846
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=F00000QGAA FundId=FS00009ER5 CUSIP=66538A174 start_date=19401 end_date=. manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37847
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=F00000QGAB FundId=FS00009ER5 CUSIP=66538A166 start_date=19401 end_date=. manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37848
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=F00000O00C FundId=FS00009ER5 CUSIP=66538A471 start_date=19401 end_date=. manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37849
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=F00000O00B FundId=FS00009ER5 CUSIP=66538A489 start_date=19401 end_date=. manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37850
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA009OW FundId=FSUSA004FR CUSIP=643642101 start_date=19106 end_date=20392 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37851
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00FWZ FundId=FSUSA008ZB CUSIP=69338T765 start_date=13747 end_date=15106 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37852
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00EFE FundId=FSUSA001YA CUSIP=69338T773 start_date=13531 end_date=15106 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37853
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00J54 FundId=FSUSA0040N CUSIP=693389579 start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37854
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA05FX4 FundId=FSUSA0040N CUSIP= start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37855
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00KL4 FundId=FSUSA0040N CUSIP=693389553 start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37856
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00G3O FundId=FSUSA0040N CUSIP=693389587 start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37857
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00JM0 FundId=FSUSA0040N CUSIP=693389595 start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37858
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00HQ8 FundId=FSUSA0040N CUSIP=693389603 start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37859
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA00K4L FundId=FSUSA0040N CUSIP=693389561 start_date=14070 end_date=15991 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37860
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA02T5K FundId=FSUSA003I3 CUSIP=69338V158 start_date=14425 end_date=14861 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37861
NOTE: Invalid argument to function INPUT at line 358 column 45.
SecId=FOUSA05FUI FundId=FSUSA003I3 CUSIP= start_date=14425 end_date=14861 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37862
NOTE: Invalid argument to function INPUT at line 358 column 45.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
SecId=FOUSA00KAC FundId=FSUSA003I3 CUSIP=69338V208 start_date=14425 end_date=14861 manager_name=David M. Stein
source=http://www.bloomberg.com/research/stocks/private/person.asp?personId=25130402&privcapId=102320489 birthdate=.
OtherDegree= CFA=T MBAYear=. PHDYear=. sex=M CFAYear=. BAYear=. MAYear= OtherYear=. BAUniv=U of the Witwatersrand
BACollege= BAUniv_Country=South Africa BAUniv_State= BAUniv_Address= MAUniv=U of the Witwatersrand MACollege=
MAUniv_Country=South Africa MAUniv_State= MAUniv_Address= MBAUniv= MBACollege= MBAUniv_Country= MBAUniv_State=
MBAUniv_Address= PhDUniv=Harvard U PhDCollege= PhDUniv_Country= PhDUniv_State=Massachusetts
PhDUniv_Address=Cambridge, MA 02138 OtherUniv= OtherCollege= OtherUniv_Country= OtherUniv_State= OtherUniv_Address=
BAMajor1= BAMajor2= BAMajor3= BAMajor4= BAMajor5= MAMajor1= MAMajor2= MAMajor3= MAMajor4= MAMajor5=
PhDMajor1=Applied Mathematics PhDMajor2= PhDMajor3= BAMajor1_code=. BAMajor2_code=. BAMajor3_code=. BAMajor4_code=.
BAMajor5_code=. MAMajor1_code=. MAMajor2_code=. MAMajor3_code=. MAMajor4_code=. MAMajor5_code=. PhDMajor1_code=541
PhDMajor2_code=. PhDMajor3_code=. _ERROR_=1 _N_=37863
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
It's pretty long and the variable names in the actual data set is much more than the simple code that I posted. It seems sth to do with missing values of the birthdate variable.
You can't change a variable type in a data step. Since birthdate is already a character variable, the new variable needs a new name.
data birthdate;
set birthdate_raw;
if length(birthdate)=4 then birthdate_sas=mdy(6,30,input(birthdate,4.));
else if length(birthdate)=10 then birthdate_sas=input(birthdate,mmddyy10.);
else birthdate_sas=.;
run;
@Sejin wrote:
Hello.
I have a dataset that has a birthdate variable but in different form.
There are three types of birthdate value.
First one is 4 characters that represent year. (e.g. 1993)
Second one is 10 characters that represent mm-dd-yyyy. (e.g. 03-06-1965)
And the final one is missing value. (e.g. )
The birthdate variable is formatted as $10.
Now, I want to change the birthdate variable as date format.
Below is a code that I wrote to get what I want.
However, I got error message when I ran the code.
Could anybody give some ideas about this issye?
Thank you.
data birthdate;
set birthdate_raw;
if length(birthdate)=4 then birthdate=mdy(6,30,input(birthdate,4.));
else if length(birthdate)=10 then birthdate=input(birthdate,mmddyy10.);
else birthdate=.;
run;
Thanks for the reply!
I tried the code you suggested but I get exactly same errors.
Post your code, log and the output from a proc contents on your input data set.
@Sejin wrote:
Thanks for the reply!
I tried the code you suggested but I get exactly same errors.
In the mean time, I found what happend to my dataset.
There were few observations in the form of ddmmyy10. istead of mmddyy10.
I changed my code into like this
data man. manager_info_full_match_date_rv;
set man. manager_info_full_match;
if length(birthdate)=4 then n_birthdate=mdy(6,30,input(birthdate,4.));
else if length(birthdate)=9 and input(scan(birthdate,1,"/"),best2.)>12 then n_birthdate=input("0"||birthdate,ddmmyy10.);
else if length(birthdate)=9 and input(scan(birthdate,1,"/"),best2.)<=12 then n_birthdate=input("0"||birthdate,mmddyy10.);
else if length(birthdate)=10 and input(scan(birthdate,1,"/"),best2.)>12 then n_birthdate=input(birthdate,ddmmyy10.);
else if length(birthdate)=10 and input(scan(birthdate,1,"/"),best2.)<=12 then n_birthdate=input(birthdate,mmddyy10.);
else n_birthdate=.;
run;
Now, I got the result that I sought for.
Again, thanks for the reply.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.