BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ccaudillo100
Obsidian | Level 7

So I am trying to edit a table in SAS where the name shows up on the side of the data instead of above. The table looks like: 

 

A Offered Answered IN OUT
Christina        
mapping 1 1 :00:03 :00:00
Bob        
mapping 2 2 :01:05 :00:00

 

 

What I would like it to be is 

 

Name Type Offered Answered IN OUT
Christina mapping 1 1 :00:03 :00:00
Bob mapping 2 2 :01:05 :00:00

 

 

Any advice on how to code this?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Looks like you are trying to read in a REPORT instead of an actual dataset.  How did you create the dataset?

 

Your code is close, but you need to RETAIN the new variable that has the block header so that is stays the same for all of the rows displayed under the block header.

data have;
  input A :$20. Offered  Answered  IN $ OUT $;
cards;
Christina .  .    .      .   
mapping   1  1 :00:03 :00:00
Bob       .  .    .      .   
mapping   2  2 :01:05 :00:00
;

data want;
  length name type $20;
  set have;
  if missing(offered) then do;
    name=A;
    delete;
  end;
  type=A ;
  drop A;
  retain name;
run;

Result:

OBS    name          type      Offered    Answered      IN       OUT

 1     Christina    mapping       1           1       :00:03    :00:00
 2     Bob          mapping       2           2       :01:05    :00:00

 

View solution in original post

4 REPLIES 4
ccaudillo100
Obsidian | Level 7

 

 

I did add this code so it broke up the A column.  I have not sorted the data to change the order, so the name that is above the call information would go with the data.

 

data EditCleanup;
set cleanup;
if A = "mapping" then Type = "Mapping";
if A NE "mapping" then Name = A;
run;
ballardw
Super User

Just how was beginning "table" created? That step could very well be the place to address the issue.

 

If your data does not have other values than "mapping" for Type it is a pretty useless variable.

Or perhaps provide a more comprehensive example of the data, which is best done as data step code so we have something to run code with.

ccaudillo100
Obsidian | Level 7

This is a table I have edited down from a much bigger table that includes various types of calls that occur and time. This table is one that is like a PDF turned Excel where there are lots of merged cells and extra blank lines for no reason. I just took a basic task that I am looking to do on a large scale for confidentiality reasons.

Tom
Super User Tom
Super User

Looks like you are trying to read in a REPORT instead of an actual dataset.  How did you create the dataset?

 

Your code is close, but you need to RETAIN the new variable that has the block header so that is stays the same for all of the rows displayed under the block header.

data have;
  input A :$20. Offered  Answered  IN $ OUT $;
cards;
Christina .  .    .      .   
mapping   1  1 :00:03 :00:00
Bob       .  .    .      .   
mapping   2  2 :01:05 :00:00
;

data want;
  length name type $20;
  set have;
  if missing(offered) then do;
    name=A;
    delete;
  end;
  type=A ;
  drop A;
  retain name;
run;

Result:

OBS    name          type      Offered    Answered      IN       OUT

 1     Christina    mapping       1           1       :00:03    :00:00
 2     Bob          mapping       2           2       :01:05    :00:00

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 635 views
  • 1 like
  • 3 in conversation