turn on suggestions

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

Showing results for

Find a Community

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

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-06-2013 09:28 PM

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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-06-2013 11:02 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-07-2013 03:36 PM

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"

"

"