楼主: 3qsir
10132 18

标准化问题: PROC STANDARD [推广有奖]

11
3qsir 发表于 2014-3-9 19:59:36
The Procedure Transpose we are same :  
你数据集a里面有数据么?(有)
_NAME_        199007        199008        199009        199010
bm1        4.99                -3.45        8.05
bm2        3.76        -10.81        -8.46        3.05
bm3        4.9        -10        -9.17        3.31
bm4        4.25        -10.48        -9.96        3.25
bm5        4.93        -9.97        -10.32        3.13

12
intheangel 学生认证  发表于 2014-3-9 20:04:20
额,你的和我不一样,
_NAME_        199007        199008        199009        199010,
你的变量就是199007 199008 199009 199010

PROC STANDARD DATA=work.a
MEAN=0 STD=1 OUT=after;
VAR 199007 199008 199009 199010;
PROC MEANS DATA=after MAXDEC=2 MEAN STD;
RUN;

你直接写199007 199008 199009 199010 就好
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

13
intheangel 学生认证  发表于 2014-3-9 20:07:01
_NAME_ _199007 _199008 _199009 _199010
bm1 4.99 .  -3.45 8.05
bm2 3.76 -10.81 -8.46 3.05
bm3 4.90 -10.00 -9.17 3.31
bm4 4.25 -10.48 -9.96 3.25
bm5 4.93 -9.97 -10.32 3.13

这个是我的a,我们的变量名不同

我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

14
3qsir 发表于 2014-3-9 20:43:29
intheangel 发表于 2014-3-9 20:04
额,你的和我不一样,
_NAME_        199007        199008        199009        199010,
你的变量就是 ...
NOT OK ! PLS SEE Line 29 : ERROR
1                     
1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='stdize';
4          %LET _CLIENTPROJECTPATH='C:\Users\Commodity\Desktop\stand.egp';
5          %LET _CLIENTPROJECTNAME='stand.egp';
6          %LET _SASPROGRAMFILE=;
7         
8          ODS _ALL_ CLOSE;
9          OPTIONS DEV=ACTIVEX;
NOTE: Procedures may not support all options or statements for all devices. For details,
      see the documentation for each procedure.
10         GOPTIONS XPIXELS=0 YPIXELS=0;
11         FILENAME EGSR TEMP;
12         ODS tagsets.sasreport12(ID=EGSR) FILE=EGSR STYLE=Analysis
12       ! STYLESHEET=(URL="file:///C:/Program%20Files/SAS/EnterpriseGuide/4.3/Styles/Analy
12       ! sis.css") NOGTITLE NOGFOOTNOTE GPATH=&sasworklocation ENCODING=UTF8
12       ! options(rolap="on");
NOTE: Writing TAGSETS.SASREPORT12(EGSR) Body file: EGSR
13         
14         GOPTIONS ACCESSIBLE;
15         data before;
16          input ind bm1 bm2 bm3 bm4 bm5;
17          cards;

NOTE: The data set WORK.BEFORE has 4 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds
      
22          ;

23          run;
24         proc transpose out=a;
25          id ind;
26          run;

NOTE: There were 4 observations read from the data set WORK.BEFORE.
NOTE: The data set WORK.A has 5 observations and 5 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
      

27         PROC STANDARD DATA=work.a
28          MEAN=0 STD=1 OUT=after;
29          VAR 199007 199008 199009 199010;
                ______
                22
                76
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, _ALL_, _CHARACTER_,
              _CHAR_, _NUMERIC_.  
ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.AFTER may be incomplete.  When this step was stopped there were
         0 observations and 0 variables.
NOTE: PROCEDURE STANDARD used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      
30          PROC MEANS DATA=after MAXDEC=2 MEAN STD;

31          RUN;

NOTE: No variables in data set WORK.AFTER.                                 
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds
      

32         
33         
34         
35         GOPTIONS NOACCESSIBLE;
36         %LET _CLIENTTASKLABEL=;
37         %LET _CLIENTPROJECTPATH=;
38         %LET _CLIENTPROJECTNAME=;
39         %LET _SASPROGRAMFILE=;
40         
41         ;*';*";*/;quit;run;
42         ODS _ALL_ CLOSE;
43         
44         
45         QUIT; RUN;

15
intheangel 学生认证  发表于 2014-3-9 20:47:59
你 work.a 里面到底有哪几个变量啊?你变量是什么,你var 后面就写什么怎么会找不到呢?
。。。。囧。。。。;
实在不行,你把a发给我给我看
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

16
intheangel 学生认证  发表于 2014-3-9 20:53:38
what is your variable name in the table work.a?

无标题2.png (5.95 KB)

这是我的数据集work.a

这是我的数据集work.a

我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

17
3qsir 发表于 2014-3-9 22:10:09
I guess your sas edition not latest (my sas 9.2 e/d)
after sas 9 e/d the sas redefine "column name" 's string : need not first alphalnet(character)
your a column's name(_19907) different with mine (199007);
no matter what  _19907 or 199007 the procedure must use label=_19907
below  is correct answer, but error still exist on code.
I reference "SAS 精析與實例(黃俊英著)" page 223 about PROC STANDARD
PROC STANDARD DATA=work.a
MEAN=0 STD=1 OUT=after;
  VAR _199007 _199008_199009 _199010;

18
3qsir 发表于 2014-3-10 11:43:58
Thanks Sir:
Can you help another problem about macro under your given code:

I use macro to create var199101-var201312 standardize into after file,
"proc data... merge" is very weakness for me,because I will run SAS-EG on this procedure,
pls help me about merge section in the below macro code.
thanks.

%macro all(ybeggin,yend)

%do year=&ybeggin %to &yend;

PROC STANDARD DATA=work.before

       MEAN=0 STD=1 OUT=after0;

       VAR '&year.01'n '&year.02'n '&year.03'n '&year.04'n '&year.05'n '&year.06'n
           '&year.07'n '&year.08'n '&year.09'n '&year.10'n '&year.11'n '&year.12'n;

run;
/* before merge t1. IND left join after0*/

data after;
merge before after0;

%end;
PROC MEANS DATA=after MAXDEC=2 MEAN STD;

RUN;
%mend all;

19
yongyitian 发表于 2014-3-10 12:28:27
  1. /* I used the datastep to create the variable list */
  2. /* and moved the %end; to below the proc mean;*/
  3. %macro all(ybegin=,yend=);
  4.   %do year=&ybegin %to &yend;
  5.      data _null_;
  6.       length all_var $150 var $10 year $4;
  7.         do i = 1 to 12;
  8.           year="&year";  put year=;
  9.           var = cats("'", year, put(i,z2.), "'", "n"); put var=;
  10.           all_var = catx(' ', all_var, var);  put all_var=;
  11.         end;
  12.         call symput('all_var', all_var);
  13.      run;
  14.    PROC STANDARD DATA=work.before
  15.      MEAN=0 STD=1 OUT=after0;
  16.       VAR &all_var;
  17.    run;

  18. /* before merge t1. IND left join after0*/
  19.    data after;
  20.    merge before after0;
  21.    run;
  22.    PROC MEANS DATA=after MAXDEC=2 MEAN STD;
  23.    RUN;
  24.   %end;
  25. %mend all;
  26. %all(ybegin=2011,yend=2012)
复制代码

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 10:47