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;
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.
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.
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.
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.
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: