BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
3 REPLIES 3
deleted_user
Not applicable
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
deleted_user
Not applicable
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.
deleted_user
Not applicable
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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1202 views
  • 0 likes
  • 1 in conversation