BookmarkSubscribeRSS Feed
yotsuba88
Quartz | Level 8

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: 

 

momr_NAME__ewret1__Average_ret_ewret1__CAPM_Alpha_ewret1__FF3_Alpha
1param1.090.210.15
1T(6.22)(3.26)(3.08)
2param1.090.210.15
2T(6.20)(3.46)(3.42)
3param1.000.130.07
3T(5.83)(2.28)(1.71)
4param1.040.170.10
4T(6.01)(2.79)(2.34)
5param0.970.07-0.01
5T(5.33)(1.05)(-0.32)
6param0.980.06-0.03
6T(5.05)(0.77)(-0.68)
7param0.90-0.05-0.16
7T(4.30)(-0.58)(-2.98)
8param0.78-0.21-0.32
8T(3.46)(-2.00)(-5.47)
9param0.67-0.34-0.48
9T(2.77)(-2.78)(-6.66)
10param0.27-0.77-0.95
10T(1.01)(-5.10)(-10.01)
99param-0.83***-0.98***-1.10***
99T(-6.04)(-7.75)(-11.34)

 

I really appreciate if someone can help me with it. 

7 REPLIES 7
yotsuba88
Quartz | Level 8
I mean it just like Jump for 1st table, IV for 2nd table

##- Please type your reply above this line. Simple formatting, no
attachments. -##
yotsuba88
Quartz | Level 8
I have 5 datasets that contain table (all tables have the same format),
then I try to combine these 5 datasets in one file.
Is this what you mean?

Thank you.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Kurt_Bremser
Super User

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?

yotsuba88
Quartz | Level 8
The name of table is the name of file. So I am not sure if I can insert one
variable (column) and observation inside.


##- Please type your reply above this line. Simple formatting, no
attachments. -##
Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 993 views
  • 0 likes
  • 2 in conversation