BookmarkSubscribeRSS Feed
Anmolkhandelwal
Obsidian | Level 7

I have been trying to Declare an array which will be populated with values such as (0.00,25.88,25.10) ,

My declaration Looks like:  ARRAY CP_COB_REMAINING_PAT_LBLTY_AMT {9} 8.2 CP_COB_REMAINING_PAT_LBLTY_AMT1 - CP_COB_REMAINING_PAT_LBLTY_AMT9;

 

After this i am iterating over the aaray and assigning values from my input variable. 

 

Any help?

3 REPLIES 3
andreas_lds
Jade | Level 19

Please post the code using the running-man icon and post the complete data step. From the documentation:

 

Example 2: Assigning Initial Numeric Values

These examples show how to define an array and assign initial numeric values to the elements in the array.

  • array test{4} t1 t2 t3 t4 (90 80 70 70);
  • array test{4} t1-t4 (90 80 2*70);
  • array test{4} _TEMPORARY_ (90 80 70 70);

 

Amir
PROC Star

As well as posting your code as @andreas_lds advised, if you are getting any error or warning messages then please also post your log showing the code executing and the messages generated, using the "Insert Code" icon (denoted by "{i}").

 

Regards,

Amir.

FreelanceReinh
Jade | Level 19

@Anmolkhandelwal wrote:

My declaration Looks like:  ARRAY CP_COB_REMAINING_PAT_LBLTY_AMT {9} 8.2 CP_COB_REMAINING_PAT_LBLTY_AMT1 - CP_COB_REMAINING_PAT_LBLTY_AMT9;

 

Hello @Anmolkhandelwal,

 

The issue with your array declaration is that you specify a format (8.2) where SAS expects a length specification (in your case: 8). Since 8 (bytes) is the default length and numeric is the default type of variables you can even omit this length specification. Also the list of variable names is redundant in your example and can be omitted because an array of the form arrayname[N] consists of variables named arrayname1-arraynameN by default. Remember that there is no "decimal datatype" for variables in SAS datasets. For numbers of all kinds there is only one variable type "numeric" (as opposed to "character").

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 786 views
  • 0 likes
  • 4 in conversation