<% @language="vbscript" %>
Site hosted by Angelfire.com: Build your free website today!
   欢迎光临
 

Note:

  
This SAS program  can be used to modify all variable names in your dataset by adding  same characters to them . Such as if you conduct a cohort study, you have several datasets, from 1999Q1 to 2001Q4, you can add 1999Q1or  2001Q4 to all variable names in your datasets.

   

libname l'c:\';

proc import out= work.Q401 /******Need Change*********************/

datafile= "c:\yourdata.xls" /************Need change*********************/

dbms=excel2000 replace;

getnames=yes;

run;

/* Running the renaming macro */

options macrogen mprint mlogic;

%macro rename(lib,dsn);

options pageno=1 nodate;

proc contents data=&lib..&dsn;

title "Before Renaming All Variables";

run;

proc sql noprint;

select nvar into :num_vars

from dictionary.tables

where libname="&LIB" and

memname="&DSN";

select distinct(name) into :var1-

:var%TRIM(%LEFT(&num_vars))

from dictionary.columns

where libname="&LIB" and

memname="&DSN";

quit;

run;

proc datasets library=&LIB;

modify &DSN;

rename

%do i=1 %to &num_vars;

&&var&i=&&var&i.._01Q4 /*******************Need Change here********************/

%end;

;

quit;

run;

options pageno=1 nodate;

proc contents data=&lib..&dsn;

title "After Renaming All Variables";

run;

%mend rename;

%rename (WORK,Q401); /*************************** Need change here***************/

data l.renamed_data_01Q4;

set Q401;

run;

 

MOST PROGRAMS WERE WRITTEN BY MYSELF, IF NOT, SOURCE WILL BE CITED.
All RIGHT RESERVED.
FREE WEB HOST PROVIDED BY BRINKSTER.COM