The files are CSV format. I don't think the problem in the file itself. I just need to know if it's possible to match dates, if yes, what is the appropriate codes. Thanks,
can I change the date format from the original file (excel file)? will that help?
Do the changing in SAS so that you don't have to manually do it in Excel again.
Code once run many.
I have 5 files for the (ICD_Codes), so I need to truncate them as one file. when I do that, the dates get messed up. I don't know why this is happening. see the attached picture (last column).
then I did this code
data DSNEW;
set dss5;
D_DATE= input(DIAG_DT_TM,anydtdte32.);
Format D_DATE mmddyy10.;
drop DIAG_DT_TM;
run;
to fix it, and maybe I messed it up. the code was only applied for one dataset and I changed the rest by changing the excel date format.
I just want to keep only the date. I'm not interested in the time. Can I keep only the date?
@alotaibifm wrote:
I just want to keep only the date. I'm not interested in the time. Can I keep only the date?
Sure, use DATEPART() after on the variable to get just the date portion.
or TIMEPART() for the time portion.
data New_All;
set EALLD_NEW;
D_DATE= input(DIAG_DT_TM,anydtdte32.);
Format D_DATE DATE9.;
drop DIAG_DT_TM;
run;
I did it all over again, and I'm afraid that I will mess up the whole data. I reimported the CSV files through (file>import> etc) then I concatenate all the 5 files in one file. Now, I want to change the date format, so that I can merge them correctly. When I applied the code I posted here, the date shift to 5 years or so, it's not giving me the correct conversion. Do you think it's a correct code?
I imported the 5 files by (proc import) here is the code for one file:
proc import
out=library.E1
datafile='C:\Users\alotaibifm\Desktop\Study 3/export1.csv'
dbms=csv
replace;
GUESSINGROWS=MAX;
run;
when I tried to concatenate all 5 files in one file, SAS gave me this error:
4027 data library.Dall;
4028 set library.E1 library.E2 library.E3 library.E4 library.E5;
ERROR: Variable DIAG_DT_TM has been defined as both character and numeric.
ERROR: Variable DIAG_DT_TM has been defined as both character and numeric.
4029 run;
then I tried to convert the date by this code and gave me a lot of missing value.
data library.E11;
set library.E1;
Visit_Date= input(DIAG_DT_TM,anydtdte32.);
Format Visit_Date mmddyy10.;
drop DIAG_DT_TM;
run;
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 25. 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.