BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

You should have handled the missing values before you transposed it.

 

Hello_there
Lapis Lazuli | Level 10
My actual data came from PROC means and when I transposed it by visit, with id being treatment, that’s when the blanks appeared bc not every treatment had a visit
Tom
Super User Tom
Super User

@Hello_there wrote:
My actual data came from PROC means and when I transposed it by visit, with id being treatment, that’s when the blanks appeared bc not every treatment had a visit

Show the code.  I have never seen PROC MEANS make some thing that looks like '3 (4)' as output.  I generally only creates numeric values.

Hello_there
Lapis Lazuli | Level 10
That was an extra step I took to get it into the format I needed in an intermediary data step. This is my personal computer so I don’t have access to the actual output.

But when you use PROC means to get summary statistics by visit for each treatment, it only summarizes the actual data in the raw data set. When you transpose it, there will be missing values for treatments that didn’t have a visit.
For example, subjects in treatment one can have data for visit 001, but if treatment 2 doesn’t have data for visit 001, then it will be blank.

My example wasn’t really accurate in the OP bc one of the treatments has to have data for a visit to populate in the data step. If there is no data for all treatments, there are no visits.

Tom
Super User Tom
Super User

So do the step to add the visits before the proc means.  Then the step that is making it pretty for the transpose can deal with the missing values.

 

If you don't have a dataset with the set of valid id*visit combination you can easily make one.

Example:

data have;
  input id visit value ;
cards ;
1 1 100
1 2 112
2 1 200
3 2 300
;
proc sql ;
create table for_analysis as 
select * 
from have 
natural full join 
  ( select * from (select distinct id from have),(select distinct visit from have) )
;
quit;

Tom_0-1670275271466.png

 

Hello_there
Lapis Lazuli | Level 10
This works also!
Hello_there
Lapis Lazuli | Level 10
The array would be more efficient though right? Because if you did the extra step, you would still have to address the missing values at the end. But maybe this way is less lines of code.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 21 replies
  • 1316 views
  • 5 likes
  • 4 in conversation