Your SAS programs, embedded in web apps and elsewhere

sas array dynamic name

Reply
N/A
Posts: 0

sas array dynamic name

please let me know?
1)how I can define an aaray whose arguments name is my sas data set name (vars)
2)then I would like to do calculations on each var.
my data set is huge like more than 500 columns so I can not explicitly name them, is there any daynamic way?
N/A
Posts: 0

Re: sas array dynamic name

an array can hold only numeric values, or only character values, like [pre]
* presuming large table is addressable as large.dataSet;
data results ;

set large.dataSet ;

array thisC(*) _character_ ;
array thisN(*) _numeric_ ;

do col= 1 to dim( thisC ) ;
this_name = vname( thisC(col) );

* process character columns ;

end;

do col= 1 to dim( thisN ) ;
this_name = vname( thisN(col) );

* process numeric columns ;

end;

run; [/pre]

Good Luck
PeterC
N/A
Posts: 0

Re: sas array dynamic name

it is great to know this Peter, I was not ware of this function.
what I was actually trying to do is to subtract each column, my data set is lik this

cus_id Bal_1 Bal_2 ... Bal_500
1 10 15 .... 50
..

and I would like to subtract Bal_2 - Bal_1 as Net_Growth1 , then Bal_3 - Bal_2 as Net_Growth2 and so on, if I could do it in an array it is great.
N/A
Posts: 0

Re: sas array dynamic name

SAS online doc has a section on data step concepts, with a chapter on arrays at
http://support.sas.com/onlinedoc/913/getDoc/en/lrcon.hlp/a002299816.htm

That should help
Ask a Question
Discussion stats
  • 3 replies
  • 208 views
  • 0 likes
  • 1 in conversation