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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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