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 |
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.
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 |
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;
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.
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?
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.