03-28-2013 10:15 AM
Hi guys, need help plz.
I convert variable 'b' from numeric to character by applying following code and then drop 'b' and then rename a=b.
then try to bring b as first variable in dataset by using 'attrib' funtion but getting following error msg.
can you plz help?
attrib b length=5;
ERROR: variable B has been defined as both character and numeric.
03-28-2013 10:58 AM
hello sir, I did try this and it worked. I didn't drop and rename, used 'retain' function and didn't use 'length' statement ...
03-28-2013 11:07 AM
Either would have worked. However, I hope you just forgot to post the rename statement as, otherwise, the code you showed would create the new character variable a, but then put the old numeric variable b in the first position.
03-28-2013 11:18 AM
Here are some samples from support.sas.com that may be useful:
Sample 40700: How to convert all character variables to numeric and use the same variable names in the output data set
Sample 24590: Convert values from character to numeric or from numeric to character
Sample 43052: Convert variables containing only numeric values from type character to numeric
03-28-2013 11:41 AM
It would need one additional statement in order to satisfy the OP's needs:
attrib b length=$5;
Need further help from the community? Please ask a new question.