BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello!

I am having problems with the following in SAS:
I am investigating the association between parents marital status and childrens health status. I am investigating this in the time period of 1990-2005.
I can get information about parental marital status once every year - on Jan 1.
I can get information about the children continously.

So, in order to be as precise as possible, I would like to do the following:

If the child is born between Jan 1 and June 30 2000 (e.g) the information about parental marital status should be drawn on Jan 1 2000.

If the child is born between Jul 1 and December 31 2000 the information about parental marital status should be drawn on Jan 1 2001.

How can I do this in SAS?

Kind regards, Grethe
6 REPLIES 6
GertNissen
Barite | Level 11
You can test your conditions with IF staements or using SAS functions

data test;
date='1jan09'd;
date0=intnx('year',intnx('month',date,6),0);
put (_all_) (= date.);
date='1jul09'd;
date0=intnx('year',intnx('month',date,6),0);
put (_all_) (= date.);
run;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also, you might find interest in using the MONTH function to test the month-of-year values 1-6 and set your some_important_date using INTNX with 'year' (not month as shown) with the third argument of 0 -- otherwise you would use a third argument of 1 (again with 'year') to increment to the next year's start-date.

Scott Barry
SBBWorks, Inc.

data _null_;
format mybirthdate someotherdate date9.;
mybirthdate = '01aug2000'd;
if month(mybirthdate) le 6 then someotherdate = intnx('year',mybirthdate,0);
else someotherdate = intnx('year',mybirthdate,1);
putlog _all_;
run;
deleted_user
Not applicable
Thank you - both of you - for your responses!
That was a big help.

However, I have faced a new problem and need som help again.

I am working with some variables, that have quite long names. The names of the variables are made out of numbers, and I only want to use the first two numbers in the variable name, when I run the analyses. How can i do that?

I have tried to write: temp_1=(substr(variablename,1,2);

but it doesnt seem to work. What am i doing wrong?

Thank you!
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
It is most suitable and considerate to forum visitors if you open a new post when you have a new question/concern.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also, you need only submit an item in a single forum, not multiple for a given post.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Refer to duplicate post and reply here:

http://support.sas.com/forums/thread.jspa?threadID=5956&tstart=0


Scott Barry
SBBWorks, Inc.

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!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 6 replies
  • 1140 views
  • 0 likes
  • 3 in conversation