Proc tabulate data orders class customerid var

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Santa Ana Jet Stream Santa Ana Nor'easter Scirocco Mistral Delta Breeze Santa Ana Quantity 15 15 1 20 5 1 1 30 25 If you run this program on Friday, the macro processor with generate the following standard SAS code. PROC TABULATE DATA = orders; CLASS CustomerID; VAR Quantity; TABLE CustomerID ALL, Quantity; TITLE "Friday Report: Summary of Orders"; 10 SUGI 29 Tutorials And the output will look like this: Friday Report: Summary of Orders ,,... , , Quantity , , , , Sum , ^ ,CustomerID , , , ,174 , 26.00, ^ ,274 , 1.00, ^ ,287 , 85.00, ^ ,347 , 1.00, ^ ,All , 113.00, S<OE DATA-DRIVEN PROGRAMS This is where your macro programs begin to take on a life of their own. Using the CALL SYMPUT macro routine you can let a macro program look at the data and then decide for itself what to do. CALL SYMPUT takes a value from a DATA step and assigns it to a macro variable which you can then use later in your program. CALL SYMPUT can take many forms, but to assign a single value to a single macro variable, use CALL SYMPUT with this general form: CALL SYMPUT("macro-variable", value); where macro-variable is the name of a macro variable, either new or old, and is enclosed in quotes. Value is the name of a variable from a DATA step whose current value you want to assign to that macro variable. CALL SYMPUT is often used in IF-THEN statements, for example IF Place = 1 THEN CALL SYMPUT("WinningTime", Time); This statement tells SAS to create a macro variable named &WINNINGTIME and set it equal to the current value of the variable TIME when the value of Place is 1. Be careful. You cannot create a macro variable with CALL SYMPUT and use it in the same DATA step. Here's why. When you submit macro code, it is resolved by the macro processor, and then compiled and executed. Not until the final stage-- execution--does SAS see your data. CALL SYMPUT takes a data value from the execution phase, and passes it back to the macro processor for use in a later step. That's why you must put CALL SYMPUT in one DATA step, but not use...
View Full Document

This note was uploaded on 03/21/2013 for the course AMS 597 taught by Professor Xing during the Spring '11 term at SUNY Stony Brook.

Ask a homework question - tutors are online