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

Hello,

 

Below is my Proc Transpose logic however some of the records in my output is showing  blank. How can I remove the blank and have the output show on the same row?

 

Proc transpose data=Acct_Prod

out=Accts3 ( drop=_NAME_ _LABEL_);

by accno bsb Branch Openmth L3;

id month;

var accbal;

run;

 

Output as per below:

AccNobsbBranchOpenMthL3JuneJulyAugust
123456123DW31-Aug-18S5000.23  
123456123DW31-Aug-18S.5000.235000.23

 

Appreciate your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
This actually implies that your BY variables are not exactly the same for some reason. Or at least SAS doesn't think so for some reason. Not sure why, you may need to remove any leading or trailings. And if there's a different in case, ie Dw is not equal to DW then that's one thing that definitely needs to be fixed.

View solution in original post

7 REPLIES 7
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

have you tried to set prefix=month

 

novinosrin
Tourmaline | Level 20

Can you illustrate this?

 

 "How can I remove the blank and have the output show on the same row?"

Timbim
Obsidian | Level 7

I would want my result to be like the following. That's what I mean by removing the blank.

 

AccNobsbBranchOpenMthL3JuneJulyAugust
123456123DW31-Aug-18S5000.235000.235000.23

 

Thanks kindly

novinosrin
Tourmaline | Level 20

Perhaps a data model crux. A temporary solution could be another pass of the transposed dataset and update:

 


data have;
input (AccNo	bsb	Branch	OpenMth	L3	June	July	August) ($) ;
cards;
123456	123	DW	31-Aug-18	S	5000.23	 	 . .
123456	123	DW	31-Aug-18	S	.	5000.23	5000.23
;

data want;
update have(obs=0) have;
by accno bsb branch ;
run;
Reeza
Super User
This actually implies that your BY variables are not exactly the same for some reason. Or at least SAS doesn't think so for some reason. Not sure why, you may need to remove any leading or trailings. And if there's a different in case, ie Dw is not equal to DW then that's one thing that definitely needs to be fixed.
Timbim
Obsidian | Level 7

Thanks Reeza,

 

I've test the by variables and one of them was different for some reason.

 

Thanks for that.

data_null__
Jade | Level 19

This can also happen when the ID variable is also in the BY statement and can be useful if you want to create a diagonal matrix.

 

proc transpose data=sashelp.class out=agematrix;
   by name;
   id name;
   var age;
   run;

Capture.PNG

 

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 1902 views
  • 4 likes
  • 5 in conversation