From: Tom Abernathy on 18 Feb 2010 14:27 If the variable is missing then the generated variable will be missing. It sounds like you are saying that the date is either in DOF_DATE1 or DOF_DATE2. In that case you could use the COALESE function to do the IF THEN logic for you. On Feb 18, 1:16 pm, Sdlentertd <sdlente...(a)gmail.com> wrote: > On Feb 18, 9:22 am, Sdlentertd <sdlente...(a)gmail.com> wrote: > > > > > > > I am looking to convert a date to this in order to merge with another > > table: > > Rxa_date Numeric, Length 8, Format 11. and looks like 20100214 > > > I have 2 fields in another table that are dof_date1 and dof_date2: > > If one of them is populated then it is Numeric, Length 8, Format > > MMDDYY10. , and looks like 02/14/2010. if the other field is not > > populated then it is character, Length 1, Format $1. > > > I am trying to make dof_date1 and dof_date2 consistant so it matches > > to Rxa_date . > > > In the beginning the dataset looks like this: > > Number dof_date1 dof_date1 > > 22 02/14/2010 > > > Later it looks like this > > Number dof > > 22 02/14/2010 > > 22 > > I want it to look like this > > Number dof > > 22 20100214 (Numeric, Length 8, Format 11. ) > > 22 . > > > Here is what I did to make sure the formats match wether date is > > missing or not > > if dof_date1 = '' then do; > > Rxa_date = input (Date dof_date1 , DATE9.) ; END; > > else DO; FORMAT Rxa_date 11.; Rxa_date = dof_date1 ; END; > > > But it doesnt quit work because the date Rxa_date that I get is > > Numeric, Length 8, Format 11 and it looks like 18302 and not > > 20100214 > > > Thank you > > Yes, it worked Thank you... > but I noticed that sometimes the field can be numeric and then the > formula doesn't work because I need to do if -then for two cases: > populated numeric or blank character . The end results houdl be > Numeric, Length 8, Format 11 (20100214) or blank Numeric, Length 8, > Format 11 (for merger later)- Hide quoted text - > > - Show quoted text -
From: Joe Matise on 18 Feb 2010 14:52 You can't do format statements in IF statements - they execute regardless. (Same with KEEP, RENAME, LABEL, etc.) It sounds like your problem is on input of the sheet - you should try to import the sheet such that it does not have a character format when the column is empty. Are you importing it from excel? Depending no your version of SAS you have a few different ways of forcing a column to be numeric or character; let us know which version of SAS and the right solution can be provided. -Joe On Thu, Feb 18, 2010 at 10:22 AM, Sdlentertd <sdlentertd(a)gmail.com> wrote: > I am looking to convert a date to this in order to merge with another > table: > Rxa_date =96 Numeric, Length 8, Format 11. and looks like 20100214 > > I have 2 fields in another table that are dof_date1 and dof_date2: > If one of them is populated then it is Numeric, Length 8, Format > MMDDYY10. , and looks like 02/14/2010. if the other field is not > populated then it is character, Length 1, Format $1. > > I am trying to make dof_date1 and dof_date2 consistant so it matches > to Rxa_date=85. > > In the beginning the dataset looks like this: > Number dof_date1 dof_date1 > 22 02/14/2010 > > Later it looks like this > Number dof > 22 02/14/2010 > 22 > I want it to look like this > Number dof > 22 20100214 (Numeric, Length 8, Format 11. ) > 22 . > > Here is what I did to make sure the formats match wether date is > missing or not > if dof_date1 =3D '' then do; > Rxa_date =3D input (Date dof_date1 , DATE9.) ; END; > else DO; FORMAT Rxa_date 11.; Rxa_date =3D dof_date1 ; END; > > But it doesn=92t quit work because the date Rxa_date that I get is > Numeric, Length 8, Format 11 and it looks like 18302 and not > 20100214 > > Thank you >
From: Joe Matise on 18 Feb 2010 15:26 If you import from CSV, can you just hardcode the input? IE instead of PRO= C IMPORT, just write (or, copy from the log...) the code into a normal input dataset, and then just code it as date specifically? I don't know if PROC IMPORT in 9.1.3 for CSV has any dataset options to force it to numeric, perhaps one of the others will. Maybe MIXED=3DNO or YES? I don't normally use PROC IMPORT for CSVs ... -Joe On Thu, Feb 18, 2010 at 2:23 PM, TanyaDima . <sdlentertd(a)gmail.com> wrote: > Thank you for looking into this.... > my sas version is 9.1.3 and i import it from csv file and if the field > (numeric date) is not populated it automatically converts it into $1... > The raw ( import ) file cannot be changed.. thank you > > On Thu, Feb 18, 2010 at 12:52 PM, Joe Matise <snoopy369(a)gmail.com> wrote: > >> You can't do format statements in IF statements - they execute >> regardless. (Same with KEEP, RENAME, LABEL, etc.) >> >> It sounds like your problem is on input of the sheet - you should try to >> import the sheet such that it does not have a character format when the >> column is empty. Are you importing it from excel? Depending no your >> version of SAS you have a few different ways of forcing a column to be >> numeric or character; let us know which version of SAS and the right >> solution can be provided. >> >> -Joe >> >> On Thu, Feb 18, 2010 at 10:22 AM, Sdlentertd <sdlentertd(a)gmail.com>wrote= : >> >>> I am looking to convert a date to this in order to merge with another >>> table: >>> Rxa_date =96 Numeric, Length 8, Format 11. and looks like 20100214 >>> >>> I have 2 fields in another table that are dof_date1 and dof_date2: >>> If one of them is populated then it is Numeric, Length 8, Format >>> MMDDYY10. , and looks like 02/14/2010. if the other field is not >>> populated then it is character, Length 1, Format $1. >>> >>> I am trying to make dof_date1 and dof_date2 consistant so it matches >>> to Rxa_date=85. >>> >>> In the beginning the dataset looks like this: >>> Number dof_date1 dof_date1 >>> 22 02/14/2010 >>> >>> Later it looks like this >>> Number dof >>> 22 02/14/2010 >>> 22 >>> I want it to look like this >>> Number dof >>> 22 20100214 (Numeric, Length 8, Format 11. ) >>> 22 . >>> >>> Here is what I did to make sure the formats match wether date is >>> missing or not >>> if dof_date1 =3D '' then do; >>> Rxa_date =3D input (Date dof_date1 , DATE9.) ; END; >>> else DO; FORMAT Rxa_date 11.; Rxa_date =3D dof_date1 ; END; >>> >>> But it doesn=92t quit work because the date Rxa_date that I get is >>> Numeric, Length 8, Format 11 and it looks like 18302 and not >>> 20100214 >>> >>> Thank you >>> >> >> >
First
|
Prev
|
Pages: 1 2 Prev: Convert Character into numeric Next: Convert to numeric where Date field Numeric and Character |