BookmarkSubscribeRSS Feed
sasuser1031
Calcite | Level 5

I have master data of 12 months. I am caluclating value of one varible based on previous months values. I have calculated Feb values based on Jan values. Now, I want to calculate March value based on Jan and New Feb values; April value based on Jan, New Feb, New March values and so on...The new monthly value has to go in master dataset everytime. I have to use updated master file everytime. 

Can you please help me to write the loop? 

6 REPLIES 6
Shmuel
Garnet | Level 18

The answer to your question depends on your dataset format.

 

Please provide a sample data with the 12 month in it.

sasuser1031
Calcite | Level 5

I have caluclated it  for Feb and  applied back on master dataset I am just trying to iterative process for 12 months.  

 

PaigeMiller
Diamond | Level 26

@sasuser1031 wrote:

I have caluclated it  for Feb and  applied back on master dataset I am just trying to iterative process for 12 months.  

 


This completely avoids answering the question.

 

We still don't know what the calculation is that you are doing.

 

And you haven't provided an example, as was also requested.

--
Paige Miller
PaigeMiller
Diamond | Level 26

Now, I want to calculate March value based on Jan and New Feb values;

 

Explain. What is the calculation? Sum? Average? Delta? Time series prediction? arc-cosine?

--
Paige Miller
sasuser1031
Calcite | Level 5

I have caluclated it  for Feb and  applied back on master dataset I am just trying to iterative process for 12 months.  

Shmuel
Garnet | Level 18

Does this answers your question:

do i = 1 to 12;
    if i > 2 then do j=1 to i;
       <calculate month(j) depending on month(i)>
   end;
end;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 769 views
  • 0 likes
  • 3 in conversation