BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PhanS
Obsidian | Level 7

Hello,

My task is to calculate CD4 changes in 9 month and 12 months from the first test.

I do have the first date of CD4 testing with a format 'date9.' But I do not know how to command SAS to search 'a range of date' (9 month and one year) from the first date of testing.

I appreciate for any help. Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

data want;

set have;

date_9month=intnx('month',first_date,9,'s');

date_12month=intnx('month',first_date,12,'s');

run;

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

data want;

set have;

date_9month=intnx('month',first_date,9,'s');

date_12month=intnx('month',first_date,12,'s');

run;

PhanS
Obsidian | Level 7

Linlin,

Thanks for you prompt help. I am going to run the code and will follow-up results.

Phan S.

PhanS
Obsidian | Level 7

Dear Linlin,

Pls. kindly see the output below. No data for date_9month or date_12month.

Your further suggestion, I would appreciate. Thanks.

Ps

                                  first_                     date_     date_

         Obs      SOKID   cd4     cd4date         CD4PERC    9month    12month

           1      20      332     29MAY2006      36.0        .         .

           2      40      20      30JAN2003       2.0        .         .

           3      80      222     15JAN2004      17.0        .         .

           4      90      20      01DEC2003       2.0        .         .

PhanS
Obsidian | Level 7

Hi Linlin,

I did it. Thanks!

Ps

                   first_    first_                   date_        date_

      Obs SOKID    cd4       cd4date    CD4PERC       9month      12month

        1 20       332      29MAY2006   36.0       28FEB2007    29MAY2007

        2 40       20       30JAN2003   2.0        30OCT2003    30JAN2004

        3 80       222      15JAN2004   17.0       15OCT2004    15JAN2005

        4 90       20       01DEC2003   2.0        01SEP2004    01DEC2004

        5 100      580      21DEC1989   36.0       21SEP1990    21DEC1990

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 717 views
  • 1 like
  • 2 in conversation