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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1504 views
  • 0 likes
  • 1 in conversation