BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
karen8169
Obsidian | Level 7
data GDPhpf;
input DATE          y;
informat date yymmdd.;
datalines;
1947-01-01   12.607
1947-04-01   12.779
1947-07-01   12.979
1947-10-01   13.246
1948-01-01   13.395
1948-04-01   13.552
1948-07-01   13.788
1948-10-01   13.782
1949-01-01   13.738
1949-04-01   13.652
1949-07-01   13.547
1949-10-01   13.551
1950-01-01   13.506
1950-04-01   13.564
1950-07-01   13.847
1950-10-01   14.067
1951-01-01   14.539
1951-04-01   14.623
1951-07-01   14.671
1951-10-01   14.865
1952-01-01   14.883
1952-04-01   14.941
1952-07-01   15.053
1952-10-01   15.107
1953-01-01   15.124
1953-04-01   15.158
1953-07-01   15.215
1953-10-01   15.262
1954-01-01   15.326
1954-04-01   15.355
1954-07-01   15.341
1954-10-01   15.363
1955-01-01   15.422
1955-04-01   15.509
1955-07-01   15.616
1955-10-01   15.719
1956-01-01   15.875
1956-04-01   16.025
1956-07-01   16.201
1956-10-01   16.303
1957-01-01   16.487
1957-04-01   16.604
1957-07-01   16.733
1957-10-01   16.830
1958-01-01   16.970
1958-04-01   17.042
1958-07-01   17.083
1958-10-01   17.104
1959-01-01   17.189
1959-04-01   17.237
1959-07-01   17.308
1959-10-01   17.375
1960-01-01   17.410
1960-04-01   17.473
1960-07-01   17.552
1960-10-01   17.631
1961-01-01   17.651
1961-04-01   17.688
1961-07-01   17.727
1961-10-01   17.769
1962-01-01   17.859
1962-04-01   17.908
1962-07-01   17.950
1962-10-01   17.992
1963-01-01   18.080
1963-04-01   18.094
1963-07-01   18.112
1963-10-01   18.231
1964-01-01   18.300
1964-04-01   18.355
1964-07-01   18.447
1964-10-01   18.526
1965-01-01   18.606
1965-04-01   18.692
1965-07-01   18.778
1965-10-01   18.900
1966-01-01   19.016
1966-04-01   19.189
1966-07-01   19.359
1966-10-01   19.518
1967-01-01   19.600
1967-04-01   19.717
1967-07-01   19.894
1967-10-01   20.112
1968-01-01   20.332
1968-04-01   20.559
1968-07-01   20.757
1968-10-01   21.047
1969-01-01   21.259
1969-04-01   21.540
1969-07-01   21.847
1969-10-01   22.120
1970-01-01   22.425
1970-04-01   22.749
1970-07-01   22.935
1970-10-01   23.234
1971-01-01   23.589
1971-04-01   23.905
1971-07-01   24.146
1971-10-01   24.345
1972-01-01   24.742
1972-04-01   24.891
1972-07-01   25.111
1972-10-01   25.394
1973-01-01   25.720
1973-04-01   26.142
1973-07-01   26.631
1973-10-01   27.092
1974-01-01   27.644
1974-04-01   28.262
1974-07-01   29.124
1974-10-01   30.008
1975-01-01   30.686
1975-04-01   31.134
1975-07-01   31.688
1975-10-01   32.216
1976-01-01   32.563
1976-04-01   32.889
1976-07-01   33.309
1976-10-01   33.868
1977-01-01   34.411
1977-04-01   34.952
1977-07-01   35.437
1977-10-01   36.034
1978-01-01   36.637
1978-04-01   37.338
1978-07-01   37.987
1978-10-01   38.759
1979-01-01   39.470
1979-04-01   40.411
1979-07-01   41.235
1979-10-01   42.044
1980-01-01   42.955
1980-04-01   43.895
1980-07-01   44.903
1980-10-01   46.165
1981-01-01   47.358
1981-04-01   48.197
1981-07-01   49.096
1981-10-01   49.980
1982-01-01   50.652
1982-04-01   51.278
1982-07-01   52.001
1982-10-01   52.566
1983-01-01   53.013
1983-04-01   53.371
1983-07-01   53.929
1983-10-01   54.320
1984-01-01   54.885
1984-04-01   55.370
1984-07-01   55.827
1984-10-01   56.174
1985-01-01   56.839
1985-04-01   57.161
1985-07-01   57.528
1985-10-01   57.837
1986-01-01   58.118
1986-04-01   58.334
1986-07-01   58.606
1986-10-01   58.960
1987-01-01   59.306
1987-04-01   59.694
1987-07-01   60.135
1987-10-01   60.605
1988-01-01   61.075
1988-04-01   61.681
1988-07-01   62.426
1988-10-01   62.961
1989-01-01   63.602
1989-04-01   64.271
1989-07-01   64.744
1989-10-01   65.174
1990-01-01   65.901
1990-04-01   66.580
1990-07-01   67.180
1990-10-01   67.702
1991-01-01   68.373
1991-04-01   68.832
1991-07-01   69.328
1991-10-01   69.694
1992-01-01   70.014
1992-04-01   70.457
1992-07-01   70.785
1992-10-01   71.275
1993-01-01   71.704
1993-04-01   72.136
1993-07-01   72.504
1993-10-01   72.913
1994-01-01   73.291
1994-04-01   73.652
1994-07-01   74.021
1994-10-01   74.440
1995-01-01   74.890
1995-04-01   75.226
1995-07-01   75.548
1995-10-01   75.908
1996-01-01   76.296
1996-04-01   76.584
1996-07-01   76.932
1996-10-01   77.257
1997-01-01   77.637
1997-04-01   77.998
1997-07-01   78.225
1997-10-01   78.493
1998-01-01   78.606
1998-04-01   78.786
1998-07-01   79.071
1998-10-01   79.278
1999-01-01   79.575
1999-04-01   79.908
1999-07-01   80.191
1999-10-01   80.585
2000-01-01   81.184
2000-04-01   81.631
2000-07-01   82.154
2000-10-01   82.591
2001-01-01   83.117
2001-04-01   83.699
2001-07-01   83.970
2001-10-01   84.233
2002-01-01   84.480
2002-04-01   84.829
2002-07-01   85.204
2002-10-01   85.649
2003-01-01   86.184
2003-04-01   86.463
2003-07-01   86.932
2003-10-01   87.363
2004-01-01   88.115
2004-04-01   88.856
2004-07-01   89.438
2004-10-01   90.063
2005-01-01   90.894
2005-04-01   91.549
2005-07-01   92.399
2005-10-01   93.098
2006-01-01   93.816
2006-04-01   94.589
2006-07-01   95.250
2006-10-01   95.591
2007-01-01   96.659
2007-04-01   97.216
2007-07-01   97.538
2007-10-01   97.945
2008-01-01   98.506
2008-04-01   98.941
2008-07-01   99.619
2008-10-01   99.805
2009-01-01  100.045
2009-04-01   99.889
2009-07-01   99.882
2009-10-01  100.183
2010-01-01  100.517
2010-04-01  100.981
2010-07-01  101.444
2010-10-01  101.963
2011-01-01  102.409
2011-04-01  103.170
2011-07-01  103.770
2011-10-01  103.913
2012-01-01  104.466
2012-04-01  104.930
2012-07-01  105.547
2012-10-01  105.937
2013-01-01  106.318
2013-04-01  106.565
2013-07-01  107.112
2013-10-01  107.674
2014-01-01  108.140
2014-04-01  108.714
2014-07-01  109.178
2014-10-01  109.321
2015-01-01  109.307
2015-04-01  109.922
2015-07-01  110.268
2015-10-01  110.498
2016-01-01  110.635
2016-04-01  111.268
2016-07-01  111.662
;


proc expand data = GDPhpf out=GDPhpf1 method=none;
id date;
convert y=yHPT/ transformout = (hp_t 1600);
convert y=yHPC/ transformout = (hp_c 1600);
convert y=yHPT_1/ transformout = (hp_t 400);
convert y=yHPC_1/ transformout = (hp_c 400);
convert y=yHPT_2/ transformout = (hp_t 6.25);
convert y=yHPC_2/ transformout = (hp_c 6.25);
run;
Data GDPhpf;
set GDPhpf1;
trend = yHPT;
cycle= y-trend;
pct_cycle=cycle*100;
label pct_cycle='Devision from Trend : Cyclical/Transitory Component';
run;

proc sgplot data= GDPhpf;
title 'Trend';
series x=date y=yHPT;
series x=date y=yHPT_1;
series x=date y=yHPT_2;
run;

proc sgplot data= GDPhpf;
title 'Cycle';
series x=date y=yHPC;
series x=date y=yHPC_1;
series x=date y=yHPC_2;
run;

I want to convert the date and lower the frequence. But I failed.

It seems that I failed to write the date code. Where I can correct it? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
LaurieF
Barite | Level 11

I know next to nothing about proc expand - but does it make any difference if you tell SAS that your date variable is really a date?

 

If you change the informat line to:

attrib date informat=yymmdd. format=yymmdd10.;

does it make any difference? I wonder if currently SAS is just seeing it as an integer.

 

Can you post the error message?

View solution in original post

3 REPLIES 3
LaurieF
Barite | Level 11

I know next to nothing about proc expand - but does it make any difference if you tell SAS that your date variable is really a date?

 

If you change the informat line to:

attrib date informat=yymmdd. format=yymmdd10.;

does it make any difference? I wonder if currently SAS is just seeing it as an integer.

 

Can you post the error message?

sbxkoenk
SAS Super FREQ

Hello,

 

You need a format statement (additional to your informat statement):

 

data GDPhpf;
input DATE          y;
informat date yymmdd.;
format date yymmdd10.;
datalines;

The format statement displays the date in a human readable format.

 

The internal value of date is just an integer that represents the number of days between January 1, 1960, and your specified date.

 

To do frequency conversion, see PROC EXPAND documentation:

SAS/ETS User’s Guide

The EXPAND procedure

Details: EXPAND procedure

Frequency Conversion

http://documentation.sas.com/?docsetId=etsug&docsetVersion=14.2&docsetTarget=etsug_expand_details01....

 

Example (from QUARTER to MONTH):

proc expand data=qtrly out=temp from=qtr to=month;
   convert gdp gd / observed=average;
   id date;
run;

 

Cheers,

Koen

 

 

Reeza
Super User

If @sbxkoenk hasn't answered your question please provide more details. All we know is:

 

I want to convert the date and lower the frequence. But I failed.
It seems that I failed to write the date code. Where I can correct it? Thanks.

 

What do you mean by:

convert the date

lower the frequency - to what (weekly/monthly) and what type of aggregation is relevant (avg, mean, MJ , max)

i failed - how? What isn't doing what you want? 

 

And what do you want...I recommend posting a smaller set of data as a sample AND including what you want as output as well. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 2431 views
  • 2 likes
  • 4 in conversation