07-03-2017 02:45 AM
I have some tables that I really need to combine it together. I just want to keep momr = 1, momr=10, momr=99 for each table. And have additional column on the left side of momr, so I can put a name in.
All the tables are the same as follow:
I really appreciate if someone can help me with it.
07-03-2017 02:47 AM
What name should be contained in your new variable?
07-03-2017 03:58 AM
If you want those values automatically assigned in the data step, from where do you get them?
07-03-2017 04:14 AM
07-03-2017 04:17 AM
In your initial post, you wrote:
"And have additional column on the left side of momr, so I can put a name in."
What "name" do you want to have in this new column, and from where do you get it?
07-03-2017 04:23 AM
07-03-2017 05:04 AM
Let's make some clarifications:
- dataset: a SAS dataset; a member of a SAS library; represented physically as a .sas7bdat file in a directory for which a libname is assigned
- file: usually used for "external file", not a SAS dataset; often contains tabular data that can be imported into a SAS dataset
- observation: a single record (row) of a SAS dataset, consisting of one or more columns(variables)
- variable or column: a single piece of data within an observation; numeric or character
Try to follow this guideline in your posts to avoid confusion.
From what I guess, this might be what you are looking for:
data want; format dsname $41.; set table1 table2 table3 table4 table5 indsname=inname ; where momr in (1,10,99); dsname = inname; run;
Since the variable named as indsname can't be included in the output dataset, we have to create a suitable variable of length 41 (8 bytes max for library name, dot, 32 bytes max for dataset name) for that. Because the format statement comes before the set statement, dsname will be the first (leftmost) variable/column of the new dataset.