More information is needed.
Is 03/01/2022 in a character variable in a data set? Is it in a numeric variable in a data set? If numeric, what is the format? Is it found in a text file that you have to read into SAS? Is it something else?
I have two seprate dates in which
Dataset A has the variable due_date = 03/01/2022- type-date length-8
Dataset B has the variable due_date = 01MAR2022:00:00:00- TYPE DATE
So I need to change the dates to same format.
Either A-B or B -A
In SAS, there is no such thing as type-date, so I don't know what you mean. Nevertheless, you have not answered my questions, so I ask again:
Is 03/01/2022 in a character variable in a data set? Is it in a numeric variable in a data set? If numeric, what is the format? Is it found in a text file that you have to read into SAS? (okay, this last one is answered, these are in SAS data sets)
The origin of the confusion is that the EG, when you hoover over variable name in open dataset, if it recognise numeric variable with date/datetime fomat it displays "date" type.
Here's some examples of using SAS Date/Time values
data work.have ; date="15APR2023"d ; /* SAS Date Constant */ put date= date= ddmmyy10. ; /* Output to the SAS log the raw date value and a formated date value */ datetime="15APR2023 11:59:59"dt ; /* SAS Date Time Constant */ put datetime= datetime= datetime. ;/* Output to the SAS log the raw datetime value and a formated datetime value */ cdate=putn(date,"mmddyy8.") ; /* Convert a SAS date value into a character variable using a format (mmddyy8.) */ put cdate= ; run ;
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.