Reputation: 233
Say I have 2 datasets
dataset1 =
123456789
222222222
444444444
dataset2 =
123456 8888 account1_description
456789 7777 account2_description
I'm trying to get a similar output as the following example
stacking the 2 datasets and having a string as indicators between
[HEADER_2015-01-01] <----inserted as a line of characters (string)
[ID] <----inserted as a line of characters (string)
123456789
222222222
444444444
[ACCOUNT] <----inserted as a line of characters (string)
123456 8888 account1_description
456789 7777 account2_description
[DETAIL] <----inserted as a line of characters (string)
my initial thought to achieve this is by creating different datasets, then append/stack them together.
for example:
dataset1(char) = [HEADER_2015-01-01]
dataset2(char) = [ID]
dataset3(number) =
123456789
222222222
444444444
dataset4(char) = [ACCOUNT]
dataset5 = ...
etc.
but obviously that's wrong because the first column (variable) is having different data formats. Can someone suggest a way to achieve this kind of output? thanks in advance.
Upvotes: 0
Views: 342
Reputation: 63424
SAS datasets are roughly analagous to SQL tables. They are not excel files. As such, it is not possible to do exactly what you're asking (have different variables on different rows).
You could have each row simply be one text string, in which case that can have whatever value you want. Or you can have different variables, stack them, and be okay that the different columns aren't aligned; it will stack fine, it just won't align the misaligned columns.
You could use SQL to UNION them and force the columns to stack, but they'd have to be the same data type.
In any event, this is not something you should do in SAS, regardless. The right way is to turn your headers into variables that have the same value for every row that should be under that header, then you could proc report
it back out with a similar structure.
Upvotes: 1