For ID variables that don't produce SAS names PROC TRANSPOSE adds _ to the value, see docs for details.
So your just need to modify your RENAME option. I would use the method in the second TRANSPOSE with FORMAT for RLTN.
input Type &$16. RLTN PARTICIPANTS;
Distribution Center 0 4
Distribution Center 1 2
Headquarters 0 8
Headquarters 1 3
Retail Store 0 4
Retail Store 1 2
PROC TRANSPOSE DATA=COMP OUT=COMP_TR
(RENAME=(_0=PART_EMPLOYEE _1=PART_SPOUSES)) ;
value rltn 0='PartEmployee' 1='PartSpouses';
PROC TRANSPOSE DATA=COMP OUT=COMP_TR(drop=_name_);
format rltn rltn.;
input gender $ id $ y;
Male A 10
Female A 5
Male B 10
proc transpose out=tall;
proc stdize out=zeroed reponly missing=0;
Great ! Thank you Data _null_. Proc STDIZE is new to me. It will suit my purpose (even though I am not familiar with it :-D ).
To your suggestion of using _0 and _1, I am finding using the Prefix option may save me some programming time. I was not familiar with the prefix option until I started researching. But thank you for your suggestion.
I have a related issue. There are no errors but I keep getting the warning that some of the drop variables are never referenced -
113 PROC TRANSPOSE DATA=COUNT OUT=COUNT_TR (DROP=_LABEL_ _NAME_) PREFIX=COUNT ;
114 BY TYPE;
115 ID RELATIONSHIP;
116 VAR COUNT;
WARNING: The variable _LABEL_ in the DROP, KEEP, or RENAME list has never been referenced.
Message was edited by: saspert
The _LABEL_ variable is only created by PROC TRANSPOSE if there are variable labels in the input data set for a variable listed in the VAR statement.
If none of those variables have labels, _LABEL_ is not created and therefore cannot be dropped. Removing _LABEL_ from the DROP= option would get rid of the warning.
If, for some reason, you must leave _LABEL_ in the DROP= option, you would get the same effect by adding a LABEL statement in the the PROC TRANSPOSE step, specifying any non-blank label for any variable in your VAR statement. The _LABEL_ column will be created, then dropped. A bit odd, but no harm, no foul.
Thank you for your suggestion. The reason I had drop= _label_ is because the _label_ field shows up in the resulting transposed dataset. Now if I remove the _label_ from the drop = list, the warning goes away but I see the field in the tranposed dataset.