You are on page 1of 3

N.

B : In order to use special characters in variable names, the VALIDVARNAME option must be set to ANY (example: options validvarname=any;). An additional method used for commenting one line of code is to use the asterisk at the beginning of the comment. Everything that is between the asterisk and the semicolon is a comment. Example: *infile 'emplist.dat'; Avoid placing the /* comment symbols in columns 1 and 2. On some operating environments, SAS may interpret these symbols as a request to end the SAS job or session. Issue the RECALL command once to recall the most recently submitted program. You can correct the unbalanced quotes programmatically by adding the following code before your previous statements: *';*";run;If the quote counter within SAS has an uneven number of quotation mark s as seen in the above program, SAS reads the quotation in the comment above as the matching quote in the quote counter. SAS then has an even number of quotes in the quote counter and runs successfully, assuming no other errors occur. Both single quota tion marks and double quotation marks are used in case you submitted double quotation marks instead of single quotation marks. Proc Contents lists the variables in the alphabatic order.Option varnam is used to list them according to they are arranged in the dataset. PROC CONTENTS DATA=LIBRARYNAME._ALL_ NODS Will give all datasets in that library. NODS-No Details. DATA Destination_Dataset_name SET Sourcs_dataset (firstobs = <> obs=<>) Used to set selected no. of observations in a new dataset. No. of records can be read by using option n in the DATA statements. Overview of PROC PRINT: You can display ?? titles and footnotes ?? descriptive column headings ?? formatted data values. ?? column totals ?? column subtotals ?? page breaks for each subgroup. The VAR statement enables you to ?? select variables to include in the report ?? define the order of the variables in the report. General form of the VAR statement: var JobCode EmpID Salary; The NOOBS option suppresses the row numbers on the left side of the report. Subsetting Data: WHERE Statement: The WHERE statement ?? enables you to select observations that meet a certain condition

?? can be used with most SAS procedures. Ex. proc print data=ia.empdata noobs; var JobCode EmpID Salary; where JobCode='PILOT'; run; Requesting Column Totals: The SUM statement produces column totals. The SUM statement also produces subtotals if you print the data in groups. Ex. proc print data=ia.empdata noobs; var JobCode EmpID Salary; sum Salary; run; Sorting a SAS Data Set: To request subgroup totals in PROC PRINT, the observations in the data set must be grouped. The SORT procedure: ?? rearranges the observations in a SAS data set ?? can create a new SAS data set containing the rearranged observations ?? can sort on multiple variables ?? can sort in ascending (default) or descending order ?? does not generate printed output ?? treats missing values as the smallest possible value. Ex. proc sort data=ia.empdata; by Salary; run; proc sort data=ia.empdata out=work.jobsal; by JobCode descending Salary; run; Printing Subtotals and Grand Totals: Print the data set grouped by JobCode with a subtotal for the Salary column for each JobCode. proc sort data=ia.empdata out=work.empdata; by JobCode; run; proc print data=work.empdata; by JobCode; sum Salary; run; N.B. : Data must be indexed or in sorted order to use a BY statement in a PROC PRINT step. Use the PAGEBY statement to put each subgroup on a separate page. 1. The PAGEBY statement must be used with a BY statement. 2. The variable in the PAGEBY statement must appear in the BY statement. Ex. proc print data=work.empdata;

by JobCode; pageby JobCode; sum Salary; run;

You might also like