<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help! how to plot impulse responses result in sas ? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533744#M6228</link>
    <description>&lt;P&gt;Oh, by the way, you don't need those macros. The SAS/IML language has DO loops, so you can program the loops directly in IML. For example, the logic for the %impulse macro would look something like the following (untested, for illustration only):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* %impulse(7,20); */
nnctry = 7; nnperiod = 20;
do k = 1 to nnctry;
  ctry = P[k,1:nnctry];
  do n = 2 to nnperiod;
     m1 = nnctry*(n-1)+1;
     m2 = nnctry*n;
     ctry =  ctry//P[k,m1:m2];
  end;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Feb 2019 21:08:09 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2019-02-07T21:08:09Z</dc:date>
    <item>
      <title>Help! how to plot impulse responses result in sas ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533438#M6183</link>
      <description>&lt;P&gt;i have used the following code to generate the impulse response result tables successfully, however, i&amp;nbsp;don't know how to plot these impulse responses using codes in this context. i urgently need the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;data dd1;&lt;BR /&gt;set work.dd;&lt;BR /&gt;/* Choose a period */&lt;BR /&gt;if Year= 2015.4 then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;filename c1 "/home/m182679152860/myfolder/Impulses_2015q4.xls"; /* Excel file output name */&lt;/P&gt;&lt;P&gt;/* Macro to show impulse responses */&lt;/P&gt;&lt;P&gt;%macro impulse(nnctry,nnperiod);&lt;BR /&gt;%do k = 1 %to &amp;amp;nnctry;&lt;BR /&gt;%let ctry = P[&amp;amp;k,1:&amp;amp;nnctry];&lt;BR /&gt;%do n = 2 %to &amp;amp;nnperiod;"&lt;BR /&gt;%let m1 = %eval(&amp;amp;nnctry*(&amp;amp;n-1)+1);&lt;BR /&gt;%let m2 = %eval(&amp;amp;nnctry*(&amp;amp;n));&lt;BR /&gt;ctry&amp;amp;k = &amp;amp;ctry//P[&amp;amp;k,&amp;amp;m1:&amp;amp;m2];&lt;BR /&gt;%let ctry = ctry&amp;amp;k;&lt;BR /&gt;%end;&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Macro to show cumulative impulse responses after 4 quarters */&lt;BR /&gt;%macro cumirf(nnctry);&lt;BR /&gt;%let irf = ctry1[1,1:&amp;amp;nnctry]+ctry1[2,1:&amp;amp;nnctry]+ctry1[3,1:&amp;amp;nnctry]+ctry1[4,1:&amp;amp;nnctry];&lt;BR /&gt;%do n = 2 %to &amp;amp;nnctry;&lt;BR /&gt;%let irf1 = ctry&amp;amp;n[1,1:&amp;amp;nnctry]+ctry&amp;amp;n[2,1:&amp;amp;nnctry]+ctry&amp;amp;n[3,1:&amp;amp;nnctry]+ctry&amp;amp;n[4,1:&amp;amp;nnctry];&lt;BR /&gt;irfcum = &amp;amp;irf//&amp;amp;irf1;&lt;BR /&gt;%let irf = irfcum;&lt;BR /&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;data est;&lt;BR /&gt;set est1.est1;&lt;BR /&gt;a5=-a5; b5=-b5; c5=-c5; d5=-d5; e5=-e5; f5=-f5; g5=-g5;&lt;BR /&gt;z1=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;reset noname;&lt;BR /&gt;use est;&lt;BR /&gt;read all;&lt;/P&gt;&lt;P&gt;r0_1= z1||a5||a5||a5||a5||a5||a5;&lt;BR /&gt;r0_2= b5||z1||b5||b5||b5||b5||b5;&lt;BR /&gt;r0_3= c5||c5||z1||c5||c5||c5||c5;&lt;BR /&gt;r0_4= d5||d5||d5||z1||d5||d5||d5;&lt;BR /&gt;r0_5= e5||e5||e5||e5||z1||e5||e5;&lt;BR /&gt;r0_6= f5||f5||f5||f5||f5||z1||f5;&lt;BR /&gt;r0_7= g5||g5||g5||g5||g5||g5||z1;&lt;BR /&gt;BB0=r0_1//r0_2//r0_3//r0_4//r0_5//r0_6//r0_7;&lt;/P&gt;&lt;P&gt;r1_1= a1||a6||a6||a6||a6||a6||a6;&lt;BR /&gt;r1_2= b6||b1||b6||b6||b6||b6||b6;&lt;BR /&gt;r1_3= c6||c6||c1||c6||c6||c6||c6;&lt;BR /&gt;r1_4= d6||d6||d6||d1||d6||d6||d6;&lt;BR /&gt;r1_5= e6||e6||e6||e6||e1||e6||e6;&lt;BR /&gt;r1_6= f6||f6||f6||f6||f6||f1||f6;&lt;BR /&gt;r1_7= g6||g6||g6||g6||g6||g6||g1;&lt;/P&gt;&lt;P&gt;BB1=r1_1//r1_2//r1_3//r1_4//r1_5//r1_6//r1_7;&lt;/P&gt;&lt;P&gt;C=a0//b0//c0//d0//e0//f0//g0;&lt;/P&gt;&lt;P&gt;/*Weighting matrix*/&lt;BR /&gt;use dd1;&lt;BR /&gt;read all;&lt;BR /&gt;W1=W1_1||W1_2||W1_3||W1_4||W1_5||W1_6||W1_7;&lt;BR /&gt;W2=W2_1||W2_2||W2_3||W2_4||W2_5||W2_6||W2_7;&lt;BR /&gt;W3=W3_1||W3_2||W3_3||W3_4||W3_5||W3_6||W3_7;&lt;BR /&gt;W4=W4_1||W4_2||W4_3||W4_4||W4_5||W4_6||W4_7;&lt;BR /&gt;W5=W5_1||W5_2||W5_3||W5_4||W5_5||W5_6||W5_7;&lt;BR /&gt;W6=W6_1||W6_2||W6_3||W6_4||W6_5||W6_6||W6_7;&lt;BR /&gt;W7=W7_1||W7_2||W7_3||W7_4||W7_5||W7_6||W7_7;&lt;/P&gt;&lt;P&gt;W=W1//W2//W3//W4//W5//W6//W7;&lt;/P&gt;&lt;P&gt;BW0=BB0#W;&lt;/P&gt;&lt;P&gt;BW1=-BB1#W;&lt;/P&gt;&lt;P&gt;invBW0=inv(BW0);&lt;/P&gt;&lt;P&gt;A0=invBW0*C;&lt;/P&gt;&lt;P&gt;A1=-invBW0*BW1;&lt;BR /&gt;I7=I(7);&lt;BR /&gt;CC={SA,US,CHINA,INDIA,JAPAN,BRAZIL,EU};&lt;/P&gt;&lt;P&gt;AR = BW0||BW1;&lt;BR /&gt;MA = I7;&lt;/P&gt;&lt;P&gt;P = ratio(ar, ma, 20, 7);&lt;BR /&gt;%impulse(7,20);&lt;BR /&gt;%cumirf(7);&lt;/P&gt;&lt;P&gt;/*Generate output to excel file*/&lt;BR /&gt;ods tagsets.excelxp&lt;BR /&gt;file=c1&lt;BR /&gt;style=minimal;&lt;BR /&gt;print 'Weighting matrix',W[colname=cc format=5.5];&lt;BR /&gt;print 'SA impulse responses',ctry1[colname=cc format=5.3];&lt;BR /&gt;print 'US impulse responses',ctry2[colname=cc format=5.3];&lt;BR /&gt;print 'China impulse responses',ctry3[colname=cc format=5.3];&lt;BR /&gt;print 'India impulse responses',ctry4[colname=cc format=5.3];&lt;BR /&gt;print 'Japan impulse responses',ctry5[colname=cc format=5.3];&lt;BR /&gt;print 'Brazil impulse responses',ctry6[colname=cc format=5.3];&lt;BR /&gt;print 'Cumulative impulse responses after 4 quarters', irfcum[colname=cc format=5.3];&lt;BR /&gt;ods tagsets.excelxp close;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 22:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533438#M6183</guid>
      <dc:creator>linaad</dc:creator>
      <dc:date>2019-02-06T22:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help! how to plot impulse responses result in sas ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533578#M6200</link>
      <description>&lt;P&gt;Without data, I cannot run your program. I also do not know what an impulse response is. It looks like maybe you want a plot of the countries/regions versus the ctry1-ctry6 values(?), But do you want a bar chart? A needle plot? Or even a line plot?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will have the most flexibility if you&lt;A href="https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html" target="_self"&gt; write the values from the IML vectors into a SAS data set&lt;/A&gt;&amp;nbsp;and then use PROC SGPLOT to plot the data. I have invented some data for illustration. The following calls create&amp;nbsp;a bar plot and a needle plot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
length CC $6;
input CC ctry;
datalines;
SA     1.2
US     3.4
CHINA  5.6
INDIA  4.7
JAPAN  3.8
BRAZIL 2.9
EU     4.0
;

proc sgplot data=Have;
   vbar CC / response=ctry;
run;

proc sgplot data=Have;
   needle x=CC y=ctry / markers;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 13:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533578#M6200</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-02-07T13:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help! how to plot impulse responses result in sas ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533700#M6225</link>
      <description>&lt;P&gt;thank you very much.&amp;nbsp; the attachment is my data set, how can i read this into a new data set by using proc sgplot&amp;nbsp;?&amp;nbsp;what i&amp;nbsp;should i&amp;nbsp;write under datalines?&amp;nbsp; and what syntax should use instead of " needle" and "graph"it out in sas?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;this is the graph that i want to produce via sas.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-02-08 at 03.22.05.png" style="width: 373px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26954i677E2A03A6C36A03/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-02-08 at 03.22.05.png" alt="Screen Shot 2019-02-08 at 03.22.05.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 19:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533700#M6225</guid>
      <dc:creator>linaad</dc:creator>
      <dc:date>2019-02-07T19:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help! how to plot impulse responses result in sas ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533709#M6226</link>
      <description>&lt;P&gt;Since you are a beginner, and the data is in separate variables, the simplest syntax is to use multiple SERIES statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Title "Chart Title";
proc sgplot data=MyData;
series x=Time y=SA;
series x=Time y=US;
series x=Time y=CHINA;
series x=Time y=INDIA;
series x=Time y=JAPAN;
series x=Time y=BRAZIL;
series x=Time y=EU;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'll leave it to others to show you how to get the data into a SAS data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 19:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533709#M6226</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-02-07T19:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help! how to plot impulse responses result in sas ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533744#M6228</link>
      <description>&lt;P&gt;Oh, by the way, you don't need those macros. The SAS/IML language has DO loops, so you can program the loops directly in IML. For example, the logic for the %impulse macro would look something like the following (untested, for illustration only):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* %impulse(7,20); */
nnctry = 7; nnperiod = 20;
do k = 1 to nnctry;
  ctry = P[k,1:nnctry];
  do n = 2 to nnperiod;
     m1 = nnctry*(n-1)+1;
     m2 = nnctry*n;
     ctry =  ctry//P[k,m1:m2];
  end;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 21:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533744#M6228</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-02-07T21:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help! how to plot impulse responses result in sas ?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533847#M6236</link>
      <description>&lt;P&gt;thank you very much, i have figured it out.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 05:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-how-to-plot-impulse-responses-result-in-sas/m-p/533847#M6236</guid>
      <dc:creator>linaad</dc:creator>
      <dc:date>2019-02-08T05:08:45Z</dc:date>
    </item>
  </channel>
</rss>

