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 (October 1996, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 3 Oct 1996 06:28:56 GMT
Reply-To:     Inus van Sandwyk <gnfmcmvs@FRM.UOVS.AC.ZA>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Inus van Sandwyk <gnfmcmvs@FRM.UOVS.AC.ZA>
Organization: University Free State
Subject:      Re: Convert many CHAR variables to NUM easily?

/*-----------------------------------------------------------------*/ /* Here is my solution of converting character variables to numeric variables, while preserving the variables labels. proc contents is used to show the state of the dataset before and after the transpose procedures */

data test; c1 = '1'; c2 = '2'; c3 = '3'; c4 = '4'; label c1 = 'Variable 1' c2 = 'Variable 2' c3 = 'Variable 3' c4 = 'Variable 4';

proc contents;

proc transpose out = trans; var c1 - c4;

data trans; set trans; numeric = input(col1,8.);

proc transpose out = orig (drop = _name_); var numeric;

proc contents; run;

/*------------------------------------------------*/ /* Output (Unnecessary lines deleted) CONTENTS PROCEDURE . . # Variable Type Len Pos Label ------------------------------------------------- 1 C1 Char 1 0 Variable 1 2 C2 Char 1 1 Variable 2 3 C3 Char 1 2 Variable 3 4 C4 Char 1 3 Variable 4 */

/* CONTENTS PROCEDURE . . # Variable Type Len Pos Label ------------------------------------------------- 1 C1 Num 8 0 Variable 1 2 C2 Num 8 8 Variable 2 3 C3 Num 8 16 Variable 3 4 C4 Num 8 24 Variable 4 */

/* Inus van Sandwyk, 1996 ------------------------*/


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