I currently have wide data that includes 35 columns for gestational age: ( ga_in_weeks_0 - ga_in_weeks_35) as well as weight_in_kgs_0 - weight_in_kgs_35 all as separate columns. I am currently trying to create long form data. I have used an array and proc transpose and both work, except when I print out the data is it missing all the information in ga_in_weeks_11 -ga_in_weeks_35. I am not sure how I am getting rid of these values when using an array or proc transpose.
DATA narrow2;
SET narrow;
ARRAY aga(0:35) ga_in_weeks_0 - ga_in_weeks_35;
ARRAY awg(0:35) weight_in_kgs_0 - weight_in_kgs_35;
DO week = 0 to 35;
ga = aga(week);
wg = awg(week);
OUTPUT ;
END;
RUN ;
or
proc transpose data=naming out= transpose1 (rename=(col1=gestationalage));
var ga_in_weeks_0 - ga_in_weeks_35;
by subject_MRN;
run;
Thank you so much in advance for any and all help.
A quick look doesn't show anything strange in your data. You have a lot of missing to start with, so when you transpose them, they're outputted as missing as well. If you want to exclude missing you need to add that into your logic, but if it's missing ahead before the transpose it will still be missing after the transpose.
1. What does the log show?
2. Can you post sample data so we can replicate the issue? If you have confidential data, please make fake data that reflects your data. There's nothing in your code to indicate that there should be an issue that I can see at a first glance, so it's likely your data has missing or something else is going on.
@arianajhnsn wrote:
I currently have wide data that includes 35 columns for gestational age: ( ga_in_weeks_0 - ga_in_weeks_35) as well as weight_in_kgs_0 - weight_in_kgs_35 all as separate columns. I am currently trying to create long form data. I have used an array and proc transpose and both work, except when I print out the data is it missing all the information in ga_in_weeks_11 -ga_in_weeks_35. I am not sure how I am getting rid of these values when using an array or proc transpose.
DATA narrow2;
SET narrow;
ARRAY aga(0:35) ga_in_weeks_0 - ga_in_weeks_35;
ARRAY awg(0:35) weight_in_kgs_0 - weight_in_kgs_35;DO week = 0 to 35;
ga = aga(week);
wg = awg(week);
OUTPUT ;
END;RUN ;
or
proc transpose data=naming out= transpose1 (rename=(col1=gestationalage));
var ga_in_weeks_0 - ga_in_weeks_35;
by subject_MRN;
run;
Thank you so much in advance for any and all help.
Hi, Thank you so much for your response.
The log shows:
A quick look doesn't show anything strange in your data. You have a lot of missing to start with, so when you transpose them, they're outputted as missing as well. If you want to exclude missing you need to add that into your logic, but if it's missing ahead before the transpose it will still be missing after the transpose.
When I run your data step code on your example dta, I get 69120 observations, as expected.
Try running it again. If still wrong, try starting a new SAS session.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.