Hello community,
I have a very large data set with many years of repeatedly measured data an over 180 variables per observations. I want to impute missing data for the first two years but converting these variables to wide format to capture record for every time of measurement and then impute is extremely tasking and the imputations are computationally demanding.
Is there any way to directly impute longitudinal data in long format using sas?
I will be glad to be advised and assisted and I wish to use FCS method in the imputaion.
Thank in advance
Are the missing variables continuous ?
An example of the before/after data would be nice too.
The are both continuous an categorical variables. The data is arranged with person
Data structure before
ID YEAR WEIGHT HEIGHT SMOKING EXERCISE
01 2000 . 175 . 1
01 2001 57 175 1 1
01 2002 . 175 . 1
01 2003 57 175 1 1
01 2004 . 175 . 1
02 2000 57 . 1 1
02 2001 . 168 . 1
02 2004 57 169 1 1
Data structure after(Only one observation per person with missing values for year 2000 values imputed .
ID YEAR WEIGHT2000 HEIGHT2000 SMOKING2000 EXERCISE2000
01 2000 57 175 1 1
02 2000 57 168 1 1
I want to have the values for the first year imputed so that I use the information for the first year in my analysis. There many observations per person and the number of observations is not similar but I want to have one summary of imputed data for each person(One entry per person).
Thank you for assistance.
I can help with your issue, but first edit your original post with a self-contained data step using datalines, posted using "Insert SAS code", that I can cut-and-paste into SAS and run without error.
DATA HAVE;
INPUT ID YEAR WEIGHT HEIGHT SMOKING EXERCISE
DATELINES;
01 2000 . 175 . 1
01 2001 57 175 1 1
01 2002 . 175 . 1
01 2003 57 175 1 1
01 2004 . 175 . 1
02 2000 57 . 1 1
02 2001 . 168 . 1
02 2004 57 169 1 1
DATA HAVE;
INPUT ID YEAR WEIGHT HEIGHT SMOKING EXERCISE
DATELINES;
01 2000 57 175 1 1
02 2000 57 168 1 1
This program is not even close to being error free.
So you want a perfectly working program that answers your question but can't be bothered supplying a working sample program?
Also why only one year in the output? Do you take the minimum non-missing value of all variables? Is this how you want to impute?
@ChrisNZ wrote:
This program is not even close to being error free.
So you want a perfectly working program that answers your question but can't be bothered supplying a working sample program?
Also why only one year in the output? Do you take the minimum non-missing value of all variables? Is this how you want to impute?
Yep, I completely agree with Chris. I know how to code this issue - it may not be perfect but would work - but refuse to expend more effort in answering your question than you (twice) expended in posting it.
Once you learn what cut-and-paste working code into SAS means, perhaps you'll get a working reply.
Here are some hints:
See, wouldn't this have been so much easier if you'd provided working code that we could run with.
Hit Google or search these forums for working examples of all the above. I'm sure you'll work it out eventually.
Good luck, I'm unsubscribing from this one...
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.