BookmarkSubscribeRSS Feed
maxime
Calcite | Level 5

Hello everyone,

I have GDP yearly forecasts, and I am trying to expand them to quarterly data. Therefore, I used the following code:

proc expand data=forecast out=quarterly from=year to=quarter;

      convert GDP / observed=(total,total);

      ID year;

   run;

I obtain an error message:

"

ERROR: Duplicate time interval found at observation number 2 in the data set FORECAST,

       according to the FROM=YEAR option and the ID variable values. The current ID is

       Year=2013 and the previous is Year=2012, which are within the same YEAR interval.

       Check that FROM=YEAR is correct for this data set, and that the ID variable Year

       contains SAS date or datetime values that correctly identify the observation"

I don't know how to solve this problem, as 2012 and 2013 are not the same year...

I noticed that if I remove the ID statement, the code works, however the first quarter is the first quarter of 1960, instead of being the first quarter of 2012. The differences in the GDP quarterly values due to that error in year must be pretty much unsignificant, but I still would like to solve it or at least understand what I did wrong or forgot!

I looked at other discussions about proc expand on this forum but I wasn't able to find a solution to my problem. Does someone have an idea that could help me?

Thank you very much!

2 REPLIES 2
damanaulakh88
Obsidian | Level 7

Hi ,


Please refer to this . I think this might help you :-


A BY statement can be used with PROC EXPAND to obtain separate analyses on observations in groups defined by the BY variables. The input data set must be sorted by the BY variables and be sorted by the ID variable within each BY group.

Use a BY statement when you want to interpolate or convert time series within levels of a cross-sectional variable. For example, suppose you have a data set STATE containing annual estimates of average disposable personal income per capita (DPI) by state and you want quarterly estimates by state. These statements convert the DPI series within each state:

   proc sort data=state;

      by state date;

   run;

   proc expand data=state out=stateqtr from=year to=qtr;

      convert dpi;

      by state;

      id date;

   run;

/Daman

maxime
Calcite | Level 5

Thank you for your help Daman!

I tried what you advised, however I don't know what to use as my by variable. I thought it would be the year, but year is also my ID variable.I think I don't have any cross-sectional variable, as I only have one value of GDP per year.

I get the error message:

"ERROR: There is only 1 usable input observation. At least 2 are required. (Some observations

       may have been ignored because of previous errors.)

NOTE: The above message was for the following BY group:

      Year=2034"

"

"

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2736 views
  • 0 likes
  • 2 in conversation