/ Published in: SAS
URL: http://studysas.blogspot.com/2009/07/even-you-can-use-hash-and-double-dash.html
In order to understand HASH and DOUBLE HASH concept in SAS you need to know about two different ranges of variables:
1) Numbered list:
When a set of variables have the same prefix, and the rest of the name is a consecutive set of numbers, we can use a single dash (-) to refer to an entire range. Some exs.. are….
VAR1 VAR2 VAR3 VAR4 VAR5
Shortcut list you can use to access all 5 variables is VAR1-VAR5
COL1 COL2 COL3 COL4 COL5 COL6 COL7
Shortcut list you can use to access all 7 variables is COL1-COL7
Expand |
Embed | Plain Text
In order to understand HASH and DOUBLE HASH concept in SAS you need to know about two different ranges of variables: 1) Numbered list: When a set of variables have the same prefix, and the rest of the name is a consecutive set of numbers, we can use a single dash (-) to refer to an entire range. Some exs.. are�. VAR1 VAR2 VAR3 VAR4 VAR5 Shortcut list you can use to access all 5 variables is VAR1-VAR5 COL1 COL2 COL3 COL4 COL5 COL6 COL7 Shortcut list you can use to access all 7 variables is COL1-COL7
Comments
Subscribe to comments
You need to login to post a comment.

In order to understand HASH and DOUBLE HASH concept in SAS you need to know about two different ranges of variables:
1) Numbered list:
When a set of variables have the same prefix, and the rest of the name is a consecutive set of numbers, we can use a single dash (-) to refer to an entire range. Some exs.. are….
VAR1 VAR2 VAR3 VAR4 VAR5
Shortcut list you can use to access all 5 variables is VAR1-VAR5
COL1 COL2 COL3 COL4 COL5 COL6 COL7
Shortcut list you can use to access all 7 variables is COL1-COL7
2) Name range list: When you refer to a list of variables in the order in which they were defined in the SAS dataset, you can use a double dash (--) to refer to the entire range of variables in between them.
Ex: VAR1 VAR2 VAR3 COUNT VAR4 COL1 VAR5
Shortcut list you can use to access all 7 variables (including COL1, which has different prefix name than others) is VAR1- -VAR5
The general rule you should always remember for dash and double dash is:
Single dash is useful to access the consequently numbered variables.
Double dash is useful to access variables based on their order/position regardless of variable name.
Execute following program in SAS to understand the concept better.
data test; var1=1; var2=2; var3=3; COL=1; var4=4; var5=5; run;
ods listing close; ods rtf file="Single DASH output.rtf" style=rtfout; title1 'Using Single DASH';
proc print data=test; var var1-var5; run;
ods rtf close; ods trace off; ods listing;
ods listing close; ods rtf file="Double DASH output.rtf" style=rtfout; title1 'Using DOUBLE DASH';
proc print data=test; var var1--var5; run;
ods rtf close; ods trace off; ods listing;