BookmarkSubscribeRSS Feed
Malathi13
Obsidian | Level 7

Hi,

I need some help in adding rows (observations) of one column to the other column from the same table. I have a table with two variables (see below).

 

Type of call           Categories

MVA                      Cardiac

Trauma                 Cardiac

No                         Respiratory

MVA                      Cardiac

NO                        Neuro

MVA                      Neuro

Trauma                 Cardiac

 

I want to add type of call to Categories so the output should look like

Type of Call           Categories

No                         Cardiac

                             Cardiac

No                         Respiratory

                             Cardiac

NO                        Neuro

                             Neuro

                            Cardiac

                            MVA

                            MVA

                            MVA

                            Trauma

                            Trauma

 

Can anybody please help me getting this output?

 

Thank you

M

3 REPLIES 3
mkeintz
PROC Star

What are the rules you wish to use to get from table1 to table2?  Please explain clearly.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Malathi13
Obsidian | Level 7

Hi,

I'm using only one table, the two columns are from the same table and I'm trying to add observations from column1 to column2.

 

 

 

M

mkeintz
PROC Star

OK, so you're trying append column 1 values to column 2, but you have not explained:

 

  1. Which values to append, since you have apparently excluded some.
  2. What order you want those appended values to have
  3. By what rule did you get an output row of "NO" and "CARDIAC"

 

We cant' read you mind, which is why we need clear and complete description of the task.

 

Also, you can help yourself if you put the starting data in the form of a sas data step, with a data set name, ,an input statement, datalines statement, and the data.

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1513 views
  • 0 likes
  • 2 in conversation