Tuesday, July 1, 2008

sas dates

Dealing with SAS dates can be tricky, particularly if you're migrating your data between different analysis platforms (SAS in UNIX, R, JMP, etc.

In order to convert a date into the sasdate, you can use one of 2 methods, depending on whether the variable was read in as a character or numeric variable.

method 1: newsasdate=input(olddate, date11.);

method 2:newsasdate=input(put(olddate, Z6.) ddmmyy6.

Monday, March 17, 2008

magic code to transform R data with 'NA' for missing to SAS '.'

array inc dlfib--dlcrp;
do i = 1 to 4;
if inc[i]='NA' then inc[i]=.;
end;
drop i;
run;