Help using Base SAS procedures

Arrays and Proc Transpose leading to missing data in the middle.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Arrays and Proc Transpose leading to missing data in the middle.

[ Edited ]

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. 


Accepted Solutions
Solution
‎04-15-2018 11:51 PM
Super User
Posts: 23,700

Re: Arrays and Proc Transpose leading to missing data in the middle.

Posted in reply to arianajhnsn

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


All Replies
Super User
Posts: 23,700

Re: Arrays and Proc Transpose leading to missing data in the middle.

Posted in reply to arianajhnsn

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. 


 

Occasional Contributor
Posts: 6

Re: Arrays and Proc Transpose leading to missing data in the middle.

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 
 
 
Attachment
Solution
‎04-15-2018 11:51 PM
Super User
Posts: 23,700

Re: Arrays and Proc Transpose leading to missing data in the middle.

Posted in reply to arianajhnsn

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. 

 

 

Esteemed Advisor
Posts: 5,526

Re: Arrays and Proc Transpose leading to missing data in the middle.

Posted in reply to arianajhnsn

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
Occasional Contributor
Posts: 6

Re: Arrays and Proc Transpose leading to missing data in the middle.

Posted in reply to arianajhnsn
Thank you so much! I was able to figure it out it was as simple as having to start fresh as you said thanks
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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