Sample 25319: Working with Numeric Variables, Chapter 6
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/**************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: BUG06U01 */
/* TITLE: Working with Numeric Variables, Chapter 6 */
/* PRODUCT: BASE */
/* SYSTEM: ALL */
/* KEYS: DOC DATASTEP PRINT VAR FUNCTION ROUND SUM */
/* PROCS: PRINT */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: SAS Language and Procedures: Usage */
/* MISC: */
/* */
/**************************************************************/
/* For simplicity the infile statement has been removed and */
/* the raw data is being read into this step via a cards */
/* statement. */
options ls=72;
title;
data tours;
input country $ 1-11 nights aircost landcost vendor $;
cards;
Japan 8 982 1020 Express
Greece 12 . 748 Express
New Zealand 16 1368 1539 Southsea
Ireland 7 787 628 Express
Venezuela 9 426 505 Mundial
Italy 8 852 598 Express
USSR 14 1106 1024 A-B-C
Switzerland 9 816 834 Tour2000
Australia 12 1299 1169 Southsea
Brazil 8 682 610 Almeida
;
run;
proc print data=tours;
title 'Data Set Tours';
run;
data newtour;
set tours;
totcost=aircost+landcost;
peakair=(aircost*1.10)+8;
nitecost=landcost/nights;
run;
proc print data=newtour;
var country nights aircost landcost totcost peakair nitecost;
title 'New Variables Containing Calculated Values';
run;
data moretour;
set tours;
roundair=round(aircost,50);
totcostr=round(aircost+landcost,100);
sumcost=sum(aircost,landcost);
roundsum=round(sum(aircost,landcost),100);
run;
proc print data=moretour;
var country aircost landcost roundair totcostr sumcost roundsum;
title 'Rounding and Summing Values';
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
These samples are from the "SAS Language and Procedures: Usage" book (No. 56075), Chapter 6.
For output and additional information on the samples refer to this book.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Functions
|
| Date Modified: | 2005-12-08 11:34:42 |
| Date Created: | 2005-05-23 13:45:42 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |