1 Data _ NULL; /* _ Null _ makes it unnecessary for the system to generate a new dataset to save memory. */ 2 Infile ' C: \ myrawdata \ candy. dat ' ; 3 Input name $ 1 - 11 Class @ 15 Datereturned mmddyy10. candytype $ quantity; 4 Profit = Quantity * 1.25 ; 5 6 /* Focus: output reports using file and put */ 7 File ' C: \ myrawdata \ student.txt ' Print;/* The file statement specifies the output path of the reprot. The print option tells SAS to include the carriage return and paging character. */ 8 Title; /* Zero title statement command SAS removes all default titles */ 9 Put @ 5 'Candy sales report For ' Name ' From Classroom ' Class 10 // @ 5'congratulations! You sold 'quantity 'boxes of candy 11 /@ 5 ' And earned ' Profit dollar6. 2 ' For our field trip ' ; 12 Put _ page _;/* Insert a paging character in each student's report */ 13 Run;
Note:
- The put statement is similar to the input statement, which can be list, column, or formatted style. However, because sas already knows whether the numeric type is variable or numeric type, you do not need to add $ to the variable;
- Like the example, the output can be combined in strings and variables.