DATA Step, Macro, Functions and more

Asterisk in Arrays

Reply
Frequent Contributor
Posts: 130

Asterisk in Arrays

Hi,

 

I am familiar with the asterisk being used in arrays when the number of arrays is not known. This is shown in the top part of the code below. However, it appears the asterisk can also be used with assignment statements, as below, in the Qtr1 assignment statement. Can someone describe how SAS uses the asteriski in the Qtr1 = Sum(of Month{*}) statement, and how sas knows how to distinguish this from the use as determining the correct number of arrays? Thanks.

 

 

Data TestPrep.SalesArray4 ; 
	Set TestPrep.Sales ;
	Array Month{*} JanSales FebSales  MarchAmt ; 
	Qtr1 = Sum(of Month{*}) ; 
run ; 

 

Super User
Super User
Posts: 8,116

Re: Asterisk in Arrays

[ Edited ]
Posted in reply to ManitobaMoose

The OF keyword allows you to use a variable list in a function call.  ARRAY_NAME(*) is an example of a variable list.

Other examples are things like

var1-var20
first -- last
prefix:
_all_
_numeric_
_character_
first-character-last
first-numeric-last

 

Super User
Posts: 23,754

Re: Asterisk in Arrays

Posted in reply to ManitobaMoose
Ask a Question
Discussion stats
  • 2 replies
  • 79 views
  • 0 likes
  • 3 in conversation