BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I ran the code as follows but I'm not receiving the output as I mentioned in the screenshot below. Appreciate if someone of you guide me here.

 

data test;
name='Van der Haeghen, Wendy (D003983)';output;
Average_Talk_Time_Answered_Calls='116,3953488';output;
name='Van der Haeghen, Wendy (D003983)';output;
Average_Talk_Time_Answered_Calls='86,66666667';output;
name='Verhaeghe, John (D002902)';output;
Average_ACW_Time_Answered_Calls='290,4883721';output;
name='Verhaeghe, John (D002902)';output;
Average_ACW_Time_AnsweredCalls='2,333333333';output;
;
run; 

Disired Output:

 

Name Average Talk Time Answered Calls Average ACW Time Answered Calls
Van der Haeghen, Wendy (D003983) 116,3953488 290,4883721
Verhaeghe, John (D002902) 86,66666667 2,333333333
7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Can I suggest you run through the training videos provided by SAS:
https://video.sas.com/

A fair few of your questions would be answered by the training given there.  In this instance you will note that if a character variable is not explicitly given a length, then it will default to 8 characters or the length of the first assigned character string.  In this case your variables have not been given a length, and hence they default to the length of the first character string.  Add

length name average_talk_time_answered_calls $200;

After the data statement to explictly set them both to 200 characters long.

Also there is a typo:

Average_ACW_Time_AnsweredCalls='2,333333333';output;

No underscore before calls. 

Babloo
Rhodochrosite | Level 12

Even after giving the length, I'm receiving the output as follows.

 

 

data test;
length name average_talk_time_answered_calls Average_ACW_Time_Answered_Calls $200;
name='Van der Haeghen, Wendy (D003983)';output;
Average_Talk_Time_Answered_Calls='116,3953488';output;
name='Van der Haeghen, Wendy (D003983)';output;
Average_Talk_Time_Answered_Calls='86,66666667';output;
name='Verhaeghe, John (D002902)';output;
Average_ACW_Time_Answered_Calls='290,4883721';output;
name='Verhaeghe, John (D002902)';output;
Average_ACW_Time_Answered_Calls='2,333333333';output;
;
run; 

Output:

 

name average_talk_time_answered_calls Average_ACW_Time_Answered_Calls
Van der Haeghen, Wendy (D003983)    
Van der Haeghen, Wendy (D003983) 116,3953488  
Van der Haeghen, Wendy (D003983) 116,3953488  
Van der Haeghen, Wendy (D003983) 86,66666667  
Verhaeghe, John (D002902) 86,66666667  
Verhaeghe, John (D002902) 86,66666667 290,4883721
Verhaeghe, John (D002902) 86,66666667 290,4883721
Verhaeghe, John (D002902) 86,66666667 2,333333333

 

 

Desired Output:

 

Name Average Talk Time Answered Calls Average ACW Time Answered Calls
Van der Haeghen, Wendy (D003983) 116,3953488 290,4883721
Verhaeghe, John (D002902) 86,66666667 2,333333333
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You have told it to "output" after every assignment.  Put an output only when you want it to write an observation out.  

data test;
  length name average_talk_time_answered_calls 
  Average_ACW_Time_Answered_Calls $200;
  name='Van der Haeghen, Wendy (D003983)';
  Average_Talk_Time_Answered_Calls='116,3953488';output;
  name='Van der Haeghen, Wendy (D003983)';
  Average_Talk_Time_Answered_Calls='86,66666667';output; 
  name='Verhaeghe, John (D002902)';
  Average_ACW_Time_Answered_Calls='290,4883721';output;
  name='Verhaeghe, John (D002902)';
  Average_ACW_Time_Answered_Calls='2,333333333';output;
;
run; 
Kurt_Bremser
Super User

You are a PROC Star, and you've been around here for some time, as the +600 posts indicate. The answer to this extremely simple issue should be glaringly obvious to you by now.

Astounding
PROC Star

In case you need a little more guidance, here's the topic you need to research.

 

WIthin a DATA step, what does an OUTPUT statement do?

novinosrin
Tourmaline | Level 20

Hi @Babloo , May i request you to phrase or frame your subject properly as opposed to "Data step". You could write something descriptive plz like "A datastep understanding issue or A data step conceptualization problem not leading to desired output? This will get wider audience and the res-ponders more interested. 

 

The videos suggested by @RW9 are excellent plus if you find yourself lagging in understanding of essentials, I would like to recommend the book of author Ron cody   https://support.sas.com/en/books/authors/ron-cody.html  Read slowly and  thoroughly 

 

And not the least,  Maxims of Maximally Efficient SAS Programmers  authored by @Kurt_Bremser will guide you on the affirmative. The idea is to pay serious and sincere attention to every maxim. 

 

 

 

ballardw
Super User

What is the reason for the Average_Talk_Time_Answered_Calls to be Character????

It won't sort, graph or do almost any analysis in a likely meaningful form.

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
  • 1025 views
  • 0 likes
  • 6 in conversation