Hi:
This is where a description and seeing the data might be useful. Given the structure that you outline, I'm not sure I understand what your macro program is actually doing. From your description, the problem sounds like a more simple transpose problem. If all you want to do is take a structure like this (showing data only...no headers)
[pre]
firm1 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
firm2 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213
firm3 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313
firm4 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413
[/pre]
And turn it into a structure like this (only 2 firms shown):
[pre]
firm1 1998 1101
firm1 1999 1102
firm1 2000 1103
firm1 2001 1104
firm1 2002 1105
firm1 2003 1106
firm1 2004 1107
firm1 2005 1108
firm1 2006 1109
firm1 2007 1110
firm1 2008 1111
firm1 2009 1112
firm1 2010 1113
firm2 1998 2201
firm2 1999 2202
firm2 2000 2203
firm2 2001 2204
firm2 2002 2205
firm2 2003 2206
firm2 2004 2207
firm2 2005 2208
firm2 2006 2209
firm2 2007 2210
firm2 2008 2211
firm2 2009 2212
firm2 2010 2213
[/pre]
Then there are a couple of things to know. First, SAS variable names can't start with a number. So your dataset variables have to be something other than 1998, 1999. In my program below, where I read in the "original" structure, I call the variable y1998, y1999, etc
[pre]
data orig_data;
length firm $8;
infile datalines dsd dlm=',';
input firm y1998 y1999 y2000 y2001 y2002 y2003 y2004 y2005 y2006 y2007 y2008 y2009 y2010;
return;
datalines;
"firm1",1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113
"firm2",2201,2202,2203,2204,2205,2206,2207,2208,2209,2210,2211,2212,2213
"firm3",3301,3302,3303,3304,3305,3306,3307,3308,3309,3310,3311,3312,3313
"firm4",4401,4402,4403,4404,4405,4406,4407,4408,4409,4410,4411,4412,4413
;
run;
proc print data=orig_data noobs;
title 'Original Data';
run;
proc sort data=orig_data;
by firm ;
run;
proc transpose data=orig_data out=panelout;
by firm ;
run;
proc print data=panelout;
title 'After Transpose';
run;
[/pre]
After the transpose step, the (partial) transposed data looks like this:
[pre]
After Transpose
Obs firm _NAME_ COL1
1 firm1 y1998 1101
2 firm1 y1999 1102
3 firm1 y2000 1103
4 firm1 y2001 1104
5 firm1 y2002 1105
6 firm1 y2003 1106
7 firm1 y2004 1107
8 firm1 y2005 1108
9 firm1 y2006 1109
10 firm1 y2007 1110
11 firm1 y2008 1111
12 firm1 y2009 1112
13 firm1 y2010 1113
14 firm2 y1998 2201
15 firm2 y1999 2202
16 firm2 y2000 2203
17 firm2 y2001 2204
18 firm2 y2002 2205
19 firm2 y2003 2206
20 firm2 y2004 2207
21 firm2 y2005 2208
22 firm2 y2006 2209
23 firm2 y2007 2210
24 firm2 y2008 2211
25 firm2 y2009 2212
26 firm2 y2010 2213
[/pre]
So from this we see that _NAME_ now holds the former variable for year and the COL1 variable holds the value for that year.
Now, all that remains is to actually make a numeric YEAR variable:
[pre]
data final_panel(keep=firm year COL1);
length year 8;
set panelout;
** get rid of 'y' in from _name_ variable to make year;
year = input(compress(_name_,'y'),4.);
run;
proc print data=final_panel noobs;
title 'After Make YEAR Variable';
run;
[/pre]
Which would result in (only partial observations shown):
[pre]
firm year COL1
firm1 1998 1101
firm1 1999 1102
firm1 2000 1103
firm1 2001 1104
firm1 2002 1105
firm1 2003 1106
firm1 2004 1107
firm1 2005 1108
firm1 2006 1109
firm1 2007 1110
firm1 2008 1111
firm1 2009 1112
firm1 2010 1113
firm2 1998 2201
firm2 1999 2202
firm2 2000 2203
firm2 2001 2204
firm2 2002 2205
firm2 2003 2206
firm2 2004 2207
firm2 2005 2208
firm2 2006 2209
firm2 2007 2210
firm2 2008 2211
firm2 2009 2212
firm2 2010 2213
[/pre]
If you wanted to rename COL1, at this point, you could use the RENAME= option in the last data set. If you do NOT already have a SAS dataset in the original structure and you need to read a dataset from some form -into- a SAS dataset, then you could also do the transpose/transform/output of one year per observation in the initial read program. But I didn't do that because you said your dataset was already in the original form.
When you are working with time series data, you frequently must transpose the entire dataset or subset in order to work with the data in your procedure of choice. There is a good section in the documentation entitled "Working with Time Series Data" that may prove very informative:
http://support.sas.com/documentation/cdl/en/etsug/63348/HTML/default/viewer.htm#/documentation/cdl/e...
cynthia