Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Re: Problem with PROC EXPAND and ID statement

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-06-2013 09:28 PM
(2736 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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"

"

"

**Available on demand!**

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

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.