Determine the last observation in a data set
Use the END= option on a SET statement to determine the last observation of the data set.
/* Create sample data */
data company;
input division :$12. employees;
datalines;
sales 150
support 200
research 250
accounting 50
shipping 35
; run;
/* Calculate the total number of employees in each group. */
/* On the last observation of the data set, write out the */
/* resulting total. */
data _null_;
set company end=last;
file print;
/* Sum statement syntax has an implied RETAIN */
total + employees;
/* For every iteration of the step, write out the values for */
/* DIVISION and EMPLOYEES. */
put @1 division @15 employees;
/* On the last iteration of the step only, write out 4 dashes */
/* starting at column 15, move the internal pointer to the next */
/* line and at column 15 write out the value of TOTAL. */
if last then put @15 '----' / @15 total;
run;
RESULT:
sales 150
support 200
research 250
accounting 50
shipping 35
----
source: http://support.sas.com/kb/24/746.html
Welcome to StudySAS, your ultimate guide to clinical data management using SAS. We cover essential topics like SDTM, CDISC standards, and Define.XML, alongside advanced PROC SQL and SAS Macros techniques. Whether you're enhancing your programming efficiency or ensuring compliance with industry standards, StudySAS offers practical tips and insights to elevate your clinical research expertise. Join us and stay ahead in the evolving world of clinical data.
Discover More Tips and Techniques on This Blog
Subscribe to:
Post Comments (Atom)
Disclosure:
In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers.
My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.
No comments:
Post a Comment