BookmarkSubscribeRSS Feed
michelle05
Fluorite | Level 6

Run the following DATA step to create a SAS data set called ABC_CORP.  Create a new SAS data set called AGES that contains all the variables in ABC_CORP plus three new variables.  One is AGE_ACTUAL, which is the exact age from DOB to January 15, 2005.  The second is AGE_TODAY, which is the age as of the date of the program is run, rounded to the nearest tenth of a year.  The third is AGE, with the fractional part dropped, as of the date stored in the variable, VISIT_DATE.  Print out a listing of this new data set.

 

***Program to create a data set ABC_CORP;

DATA ABC_CORP:

Do SUBJ = 1 to 10;

      DOB = INT (RANUNI(1234)*15000);

     VISIT_DATE = INT (RANUNI (0)*1000) + '01JAN2000'D:

     OUTPUT;

END;

FORMAT DOB VISIT_DATE DATE9.;

RUN;

4 REPLIES 4
Patrick
Opal | Level 21

@michelle05 

Do you now expect us to do all the work for you? If not then why don't you post the code you've developed already and then explain us what's not yet working and where you need help with.

michelle05
Fluorite | Level 6

Of course not!  WOW!  That was really rude.  I can post the code but when someone is trying to learn the work and is embarrassed for asking for help that makes people discouraged.  IF you are the expert in it, then a little guidance would be helpful.  I have ran the code and I keep getting several errors, so I don't know what I'm doing wrong.  Thank you for your help anyway.

Patrick
Opal | Level 21

@michelle05 

Posting code - even if not working - and eventually also the error log really helps us to understand where you're coming from so that we can give you answers on your level.

Sorry that you perceived my comment as being rude. It was more meant as a hint. Many people in the forums here appreciate if you demonstrate some own effort. You will then get a lot of help.

Patrick
Opal | Level 21

Here the fixed "Run the following DATA step to create a SAS data set called ABC_CORP." There had been some colons instead of semicolons in the syntax.

data ABC_CORP;
  Do SUBJ = 1 to 10;
    DOB = INT (RANUNI(1234)*15000);
    VISIT_DATE = INT (RANUNI (0)*1000) + '01JAN2000'D;
    OUTPUT;
  END;

  FORMAT DOB VISIT_DATE DATE9.;
  stop;
RUN;

 

I'm now really hesitant to also post all the code for "create a new dataset...". This sounds very much like an exercise so what value does it have to just throw the full solution at you? More than happy to help when you struggle - but that requires you to first post some code explaining what's not working.

This discussion and the links provided in the solution should give you guidance how to calculate the different ages.  

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 663 views
  • 0 likes
  • 2 in conversation