BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
arianajhnsn
Fluorite | Level 6

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 

 

 

View solution in original post

5 REPLIES 5
Reeza
Super User

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. 


 

arianajhnsn
Fluorite | Level 6

Hi, Thank you so much for your response.

The log shows:

NOTE: There were 1920 observations read from the data set RECODE.NAMING.
NOTE: The data set WORK.NARROW has 28800 observations and 285 variables.
NOTE: DATA statement used (Total process time):
real time 0.36 seconds
cpu time 0.30 seconds 
 
 
Reeza
Super User

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. 

 

 

PGStats
Opal | Level 21

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.

PG
arianajhnsn
Fluorite | Level 6
Thank you so much! I was able to figure it out it was as simple as having to start fresh as you said thanks

SAS Innovate 2025: Register Now

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!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1819 views
  • 3 likes
  • 3 in conversation