General form, LENGTH
statement for numeric variables:
LENGTH variable(s)
length <DEFAULT=n>;
variable(s)
specifies the name
of one or more numeric SAS variables, separated by spaces.
length
is an integer that
specifies the length of the variable(s).
DEFAULT=n
this
optional argument changes the default number of bytes that SAS uses
to store any newly created numeric variables. If you use the DEFAULT=
argument, you do not need to list any variables.
|
data reducedsales; length default=4; set sales; Sale_Percent=15; run;
Length (bytes)
|
Largest Integer Represented
Exactly
|
---|---|
3
|
8,192
|
4
|
2,097,152
|
5
|
536,870,912
|
6
|
137,438,953,472
|
7
|
35,184,372,088,832
|
8
|
9,007,199,254,740,992
|
Length (bytes)
|
Largest Integer Represented
Exactly
|
---|---|
2
|
256
|
3
|
65,536
|
4
|
16,777,216
|
5
|
4,294,967,296
|
6
|
1,099,511,627,776
|
7
|
281,474,946,710,656
|
8
|
72,057,594,037,927,936
|
General form, PROC COMPARE
step to compare two data sets:
PROC COMPARE BASE=SAS-data-set-one
COMPARE=SAS-data-set-two;
RUN;
SAS-data-set-one and SAS-data-set-two
specifies the two SAS
data sets that you want to compare.
|
Variable
|
Type
|
Length
|
Description
|
---|---|---|---|
Product_ID
|
num
|
8
|
product ID number
|
Start_Date
|
num
|
4
|
start date of sale
|
End_Date
|
num
|
5
|
end date of sale
|
Unit_Sales_Price
|
num
|
8
|
discounted sales price
per unit
|
Discount
|
num
|
8
|
discount as percent
of normal sales price
|
data company.discount_short; length Discount 4; set Company.Discount; run;
proc compare base=company.discount compare=company.discount_short; run;
Default-Length Numeric Variables
This program reads the
external data file that is referenced by the fileref Flat1 and creates
a new data set called Retail.Longnums that contains 12 numeric variables.
Each of the variables in Retail.Longnums has the default storage length
of 8 bytes. The second DATA step in this program reads the numeric
variables from Retail.Longnums.
data retail.longnums; infile flat1; input Customer_ID 12. Employee_ID 12. Street_ID 12. Order_Date date9. Delivery_Date date9. Order_ID 12. Order_Type comma16. Product_ID 12. Quantity 4. Total_Retail_Price dollar13.2 CostPrice_Per_Unit dollar13.2 Discount 5. ; run; data _null_; set retail.longnums; run; |
Reduced-Length Numeric Variables
This program reads the
external data file that is referenced by the fileref Flat1 and creates
a new SAS data set called Retail.Shortnums that contains 12 numeric
variables. A LENGTH statement is used to reduce the storage length
of most of the numeric variables in Retail.Shortnums, as follows:
The second DATA step
reads the reduced-length numeric variables from Retail.Shortnums.
data retail.shortnums; infile flat1; length Quantity Order_Type 3 Customer_ID Order_Date Delivery_Date Discount 4 Employee_ID 5 Street_ID Order_ID 6 Product_ID 7 Total_Retail_Price CostPrice_Per_Unit 8; input Customer_ID 12. Employee_ID 12. Street_ID 12. Order_Date date9. Delivery_Date date9. Order_ID 12. Order_Type comma16. Product_ID 12. Quantity 4. Total_Retail_Price dollar13.2 CostPrice_Per_Unit dollar13.2 Discount 5. ; run; data _null_; set retail.shortnums; run; |
proc compare base=retail.longnums; compare=retail.shortnums; run;