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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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