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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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