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.
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;
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;
Tom:
Thanks for providing prompt and perfect solutions to my question. It worked like a charm.
Thanks,
GPatel
Thanks for your comment. I corrected per your advice.
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!
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.