BookmarkSubscribeRSS Feed
venkatnaveen
Obsidian | Level 7
I got cmstdtc values like
            2003
            2009
            2009
           Aug 2013
          Aug-12-2014

i need to substract or add this dates with another dates which are full length dates
Aug-12-2014
June-12-2014
Apr-12-2014

7 REPLIES 7
naveen_srini
Quartz | Level 8

Well well, Have i not understood your question clearly or could you explain better please. Are you trying to extract date from the top 5 obs in your sample and then add or minus with other dates?It's difficult to understand what you are trying to achieve. Please provide your sample(have) dataset and (want) dataset.

venkatnaveen
Obsidian | Level 7

I have


2003

2007
2008
AUG-2009
AUG-2003
SEP-12-2009 and
iwant
i want results like which day the patient came to the visit
7
10
15
16
10

Reeza
Super User

So if you have 2003 what date do you want to map that to?

Same for 2007/2008?

And if you have month & year what are you assuming the day is? Can you assume the first, last or should you assume middle of the month?

venkatnaveen
Obsidian | Level 7

For anyday within a month

LinusH
Tourmaline | Level 20

You are still way to vague.

Show exactly what kind of output you desire based on input data, and try to explain in more words why/how.

Data never sleeps
Jim_G
Pyrite | Level 9

If first day of the month is OK, try this code.    Jim

data;

input  dat  $20.;

len=length(dat);     monyr='          ';

if len=4 then do;

  ndat=input(dat,4.); 

  date=mdy(1,1,ndat);

end;

if len=8 then date=input(dat,monyy10.);

if len gt 8 then do;

   mon=scan(dat,1);  day=scan(dat,2);  yr=scan(dat,3);

   *monyr=mon||yr;

   substr(monyr,1,3)=mon;  substr(monyr,4,4)=yr;

   date=input(monyr,monyy10.);

   nday=input(day,2.);  date=date+nday-1;

end;

format date  mmddyy10.;

cards;

2003

2007

2008

AUG-2009

AUG-2003

SEP-12-2009

proc print;    run;

data_null__
Jade | Level 19

In clinical trials data processing there is "always" a document that provides information on how incomplete dates (or anything else) should be imputed.  You should read that.

Perhaps something like this.

01-JUL-year when you have only the year.

15-mon-year when you have only month and year.

Sometimes the imputation is slightly different if the date is a start versus an end date.

The point is, the answer to the imputation is in the documentation for the analysis and you already have that.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1340 views
  • 0 likes
  • 6 in conversation