如何从SAS中的数据集(表)中读取值并使其成为图形的标题?

时间:2014-09-04 08:12:59

标签: graph sas

我需要你的帮助:)

我有这个表,其中包含我的图表的标题(国家行) 并尝试从Countries行读取字符串值并给出该值 到下面的SAS代码的宏变量。

但是找不到直接读取表值的方法。 任何的想法?感谢。

%macro graphing(howmanny,title_value);
    %do i=1 %to &howmanny;


        /*title = &title_value??????*/


        PROC GPLOT data=WORK.result
        ;
            PLOT Column&i * Horizental 
        RUN;

    %end;
%mend garphing;

%graphing(1);



table "Countries"
No. Countries
1   USA
2   Republic of Korea
3   China
4   Canada
5   United Kingdom
6   Deutschland
7   Swizerland
8   Italia
9   Vitetnam


--------------Work.Result table---------------------
Horizental  Colum1  Colum2  Colum3  Colum4  Colum5  Colum6  Colum7  Colum8  Colum9
1995    100 35  55  54  25  35  54  25  35
1995    95  45  55  55  26  46  55  26  46
1995    85  62  66  69  27  54  69  27  54
1995    70  73  64  69  60  66  69  60  66
1995    60  54  56  70  30  77  70  30  77
1995    55  65  65  80  65  99  80  65  99
1995    96  65  65  80  98  88  80  98  88
1995    66  65  65  90  26  99  90  26  99

2 个答案:

答案 0 :(得分:0)

使用PROC SQL INTO将相应的国家/地区名称转换为宏变量...

...
  %DO I = 1 %TO &HOWMANY ;
    proc sql noprint ;
      select Country into :CTRY
      from Countries 
      where No = &I ;
    quit ;

    title "&CTRY" ;

    ...
  %END ;
...

答案 1 :(得分:0)

或者如果你不喜欢SQL:

%DO I = 1 %TO &HOWMANY ;
    data _null_ ;
        pointer = &HOWMANY ;
        set Countries point=pointer ;
        call symputx('Country',Countries) ;
        putlog "NOTE: "Countries= ;
        stop ;
    run ;

 title "&Country." ;
[...]