While I agree with my colleagues that it would be nice to see what you've already tried, I do understand that this type of coding is probably difficult for someone who has never done it before.
The following guesses what your two files might look like (just do have some test data), the uses proc sql to create macro variables that will be used in two data steps to (1) add underscores to the start of each numeric variable ; (2) create the desired numeric variables; (3) assign the variable labels to the newly created variables; (4) reorder the variables to their original order.
You may have to do something more with the two long character variables, possibly including the STRIP function in the step that calculates the variables.
data variables;
infile cards dlm='09'x;
input vnum Variable $ Type $ Len Format $ Informat $ Label $;
cards;
64 AA Char 1 $1. $1. AA
65 AB Char 1 $1. $1. AB
86 AC Char 1 $1. $1. AC
87 AD Char 1 $1. $1. AD
88 AE Char 1 $1. $1. AE
89 AF Char 1 $1. $1. AF
31 AG Char 105 $105. $105. AG
32 AH Char 43 $43. $43. AH
33 AI Char 1 $1. $1. AI
34 AJ Char 1 $1. $1. AJ
35 AK Char 1 $1. $1. AK
36 AL Char 1 $1. $1. AL
37 AM Char 1 $1. $1. AM
90 AN Char 1 $1. $1. AN
91 AO Char 1 $1. $1. AO
92 AP Char 1 $1. $1. AP
93 AQ Char 1 $1. $1. AQ
94 AR Char 1 $1. $1. AR
95 AS Char 1 $1. $1. AS
96 AT Char 1 $1. $1. AT
97 AU Char 1 $1. $1. AU
98 AV Char 1 $1. $1. AV
99 AW Char 1 $1. $1. AW
100 AX Char 1 $1. $1. AX
101 AY Char 1 $1. $1. AY
;
data have;
input (BA BB BC BD BE BF BG BH BI BJ
BK BL BM BN BO BP BQ BR BS BT
BU BV BW BX BY BZ CA CB CC CD) ($1.)
(AG AH AI AJ AK AL AM) ($1.)
(DA DB DC DD DE DF DG DH DI DJ
DK DL DM DN DO DP DQ DR DS DT
DU DV DW DX DY DZ) ($1.)
(AA AB) ($1.)
(EA EB EC ED EE EF EG EH EI EJ
EK EL EM EN EO EP EQ ER ES ET) ($1.)
(AC AD AE AF) ($1.)
(AN AO AP AQ AR AS AT AU AV AW
AX AY) ($1.)
(FA FB) ($1.)
;
cards;
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
;
proc sql noprint;
select catx('=_',variable,variable),
catt(variable,'=input(_',variable,',8.);'),
catx(' ','label',variable,'=',Label,';')
into :renames separated by ' ',
:makenum separated by ' ',
:labels separated by ' '
from variables
;
select name
into :varorder separated by ' '
from dictionary.columns
where libname='WORK' and
memname='HAVE'
order by varnum
;
quit;
data want (drop=_:);
set have(rename=(&renames.));
&makenum.
&labels.
run;
data want;
retain &varorder.;
set want;
run;
Art, CEO, AnalystFinder.com
... View more