What i want is a table like that. Organize for Month/Year in FORMAT=MMYY7.

It was dificult to understand how to do that in SAS. How to create new columns automatic with the observations values. I think the best is in a macro. One problem is how to create a new column and not a repeated column.

Re: Create new variables based on observations to statistics

The reason its difficult to do is because it is a very bad idea. Variable names should be simple and easy to program with. Giving them the names of dates - which are an abstract concept anyways - will make your programming life a nightmare. In the worse case scenario, transpose the data up and give the variable names something like var, then apply the date as the label.

That being said, I really would not go for that data structure at all. From data which is 15*2 datapoints, you are going with a 10*5 datapoints, so effectively creating 20 datapoints with no information - bad for storage, bad for processing.

Re: Create new variables based on observations to statistics

I really wouldn't recommend it. Unless its for an output report (in which case tranpsoe before the report, or use an across statement), using normalised - data going down - is far easier to work with, smaller, and expandable endlessly. E.g

MonthYear Statistic Result

...

This dataset, you can very easily add data to , filter the data, add other statistics, sort etc. Try to do any of that with data going across, where you would need to find out what the variables are called, then loop across them, likely with big complicated messy macro code and arrays.