BookmarkSubscribeRSS Feed
anming
Pyrite | Level 9

hyphen and colon can effectively express a range, such as

 

input name $1-6   /*6 positions for a name

array score (4) score1-score4;

var1=sum(of col2-col11, of col13-col30);

sheet="name-class $A2:C6"   /*a data range of the excel sheet of class

'A' - 'F'; letters range from A to F

'A-F' a string of three characters.

 

Any other cases?

 

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

There's the double-hyphen which can be used for variable lists to denote you want consecutive variables from a data set.

 

proc print data=sashelp.class;
    var age--weight;
run;

 and a variation if you only want numeric variables in the variable list

 

proc print data=sashelp.baseball(obs=20);
    var name team crbb-numeric-salary;
run;

and a similar (and obvious) modification gets you all of the character variables in the list of variables.

--
Paige Miller
PGStats
Opal | Level 21

[a-z] describes a range of characters in a regular expression

PG
PGStats
Opal | Level 21

:Var1 - :Var4 describes a range of macro variable names in proc SQL, as in

 

select style, sqfeet
   into :type1 - :type4 notrim, :size1 - :size3
   from sasuser.houses;

 

PG

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1298 views
  • 0 likes
  • 3 in conversation