LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 8 Feb 2007 12:54:36 -0500
Reply-To:   Ya Huang <ya.huang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ya Huang <ya.huang@AMYLIN.COM>
Subject:   Re: Change variable length
Comments:   To: Ran S <raan67@YAHOO.COM>

Just use SAS meta data:

data class; set sashelp.class; run;

proc contents; run;

proc sql noprint; select trim(name)||' char(20)' into :newlen separated by ',' from dictionary.columns where libname='WORK' and memname='CLASS' and type='char' ; alter table class modify &newlen ; quit;

proc contents; run;

1 Name Char 8 24 2 Sex Char 1 32 5 Weight Num 8 16

1 Name Char 20 24 2 Sex Char 20 44 5 Weight Num 8 16

On Thu, 8 Feb 2007 11:19:29 -0500, Ran S <raan67@YAHOO.COM> wrote:

>Hi, > >I am using the following code to change the length of the variables. >How can I write global code to change the length of the variables with say >2 char to 4 char length. Because in some other dataset I might have many >variables like that. > >I would appreciate your response. >Thank you > >PROC SQL; > ALTER TABLE ATTACH > MODIFY QUESTION1 CHAR (4), QUESTION2 CHAR(4), QUESTION1 CHAR(4), >QUESTION2 CHAR(4), QUESTION3_A CHAR(4),QUESTION3_B CHAR(4),QUESTION3_C CHAR >(4),QUESTION5_A CHAR(4), QUESTION5_B CHAR(4), QUESTION5_C CHAR >(4),QUESTION5_D CHAR(4),QUESTION5_E CHAR(4),QUESTION6 CHAR(4),QUESTION7_A >CHAR(4),QUESTION7_B CHAR(4), QUESTION7_C CHAR(4),QUESTION7_D CHAR >(4),QUESTION7_E CHAR(4),QUESTION8 CHAR(4),QUESTION9_A CHAR(4), QUESTION9_B >CHAR(4), QUESTION9_C CHAR(4),QUESTION12 CHAR(4); >QUIT;


Back to: Top of message | Previous page | Main SAS-L page