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

Hi All,

I have attached sample sas dataset (human.sas7bdat).

Below is my SAS code. Upon transposing, it truncates column name ( new_name column).  Proc Transpose truncates column name ! How do I show column name displayed completely ?  

 

libname test "D:\test";
data test.human; set human; run;

proc print data=test.human ;
run;
proc sort data=test.human out=test (where=(group ne ' '));
by group dept;
run;
data test;
set test ;
length new_name $ 32767;
retain new_name;
if not missing(qq) then new_name=qq;
run;


Proc Transpose data= test Out=Human2(drop=_name_ ) ;
var response;
id new_name ;
by group dept ;

run;

proc print data=WORK.HUMAN2 ;
Title1 'Proc transpose truncated column name';
run;

>>>>>

The "new_name" column is not being shown correctly in the print output.

 

GPatel_0-1631978488437.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Your source file does not have any field you could use as the NAME of the variable.  The one you are trying to use is more appropriate as the LABEL of the variable.

Why not create variables names like Q1, Q2 etc?

data for_transpose;
  set "c:\downloads\human";
  where not missing(qq);
  length name $32 ;
  name = cats('Q',scan(scan(qq,1,'.'),-1,'#')) ;
run;

proc sort;
  by group dept name;
run;


proc transpose data=for_transpose out=want;
  by group dept ;
  id name;
  idlabel qq;
  var response;
run;

proc print data=want width=min;
run;
proc print data=want width=min label;
run;

image.png

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Your source file does not have any field you could use as the NAME of the variable.  The one you are trying to use is more appropriate as the LABEL of the variable.

Why not create variables names like Q1, Q2 etc?

data for_transpose;
  set "c:\downloads\human";
  where not missing(qq);
  length name $32 ;
  name = cats('Q',scan(scan(qq,1,'.'),-1,'#')) ;
run;

proc sort;
  by group dept name;
run;


proc transpose data=for_transpose out=want;
  by group dept ;
  id name;
  idlabel qq;
  var response;
run;

proc print data=want width=min;
run;
proc print data=want width=min label;
run;

image.png

GPatel
Pyrite | Level 9

Tom:

 

Thanks for providing prompt and perfect solutions to my question. It worked like a charm.

 

Thanks,

GPatel

 

FreelanceReinh
Jade | Level 19

@GPatel wrote:

Thanks for providing prompt and perfect solutions to my question. It worked like a charm.


@GPatel: Then it would be good to mark Tom's reply as the accepted solution, not your own "thank you" post. This can be corrected easily via the option menu (item "Not the Solution").

show_option_menu.png

GPatel
Pyrite | Level 9

Thanks for your comment.  I corrected per your advice.

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
  • 4 replies
  • 2218 views
  • 0 likes
  • 3 in conversation