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

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 927 views
  • 0 likes
  • 2 in conversation