SASomething

dm 'log;clear;output;clear;odsresult;clear;';
options missing='';
proc datasets library=work kill memtype=data nolist;
quit;
proc contents data=rawdata._all_ out=tables;run;
%let PROJDIR=Y:\Programing;
libname rawdata "&PROJDIR\02Data" access=readonly; 
libname outds "&PROJDIR\"; 
%let now= %sysfunc(today(),yymmddn8.); 
CMDESCA=translate(CMDESCA,' ','0A'x,' ','0D'x,' ','09'x);*去回车;
attrib _all_ label='';
format _all_;
informat _all_;
proc append base=all data=c;run;
proc sort data=final sortseq=linguistic(numeric_collation=on);by ord;run;
proc sort data=a2_q_3 sortseq=linguistic(locale=zh_CN collation=pinyin);by descending ord;run;
_%sysfunc(today(),yymmddn8.).xlsx
%macro get_root(ext, out);
	%local cr;
	%let cr = %sysfunc(getoption(sysin));
	
	%if (%bquote(&cr.)=) %then %do;
		%let cr = %sysget(sas_execfilepath);
	%end;

	%let cr = %upcase(&cr.);
	%let &out. = %substr(%bquote(&cr.), 1, %index(%bquote(&cr.), %bquote(%upcase(\&ext.))) - 1);
%mend;

%global dir;
%get_root(%str(program\c.sas), dir);
%put &dir.;
filename folder pipe "dir Y:\20211210\*.xlsx /b";

data files;
	infile folder truncover;
	input filename $100.;
	call symput("rows",_n_);
run;

%macro importfiles(data);
	%do i=1 %to &rows.;
		data _null_;
			set &data.;
			if _n_=&i.;
			call symput("file",filename);
			call symput("out",catt("out",&i.));
		run;
		proc import 
			datafile="Y:\20211210\&file."
			out=report.&out.
			dbms=xlsx 
			replace;
		run;
	%end;
%mend;
%importfiles(files);

proc sql;
	create table all1 as select a.*,c.RFSTDTC from all as a left join sdtm.dm as c on a.usubjid=c.usubjid;
quit;
proc sort data=all1 out=base;by usubjid qstestcd qsdtc;run;
data base2;
	set base;
	if input(qsdtc,yymmdd10.)<=input(rfstdtc,yymmdd10.);
run;
data base1;
	length QSBLFL $1.;
	set base2;
	by usubjid qstestcd qsdtc;
	if last.qstestcd;
	QSBLFL='Y';
	keep usubjid qstestcd qsdtc QSBLFL;
run;
proc sort data=all1;by usubjid qstestcd qsdtc;
proc sort data=base1;by usubjid qstestcd qsdtc;
data all2;
	merge all1 base1;
	by usubjid qstestcd qsdtc;
	if qsstat='未做' then qsblfl='';
run;
data all3;
	set all2;
	qsdy=input(QSDTC,yymmdd10.)-input(RFSTDTC,yymmdd10.)+(input(QSDTC,yymmdd10.)>=input(RFSTDTC,yymmdd10.));
run;
data all3_1(rename=(VISIT=visit1));
	set all3;
	where find(visit,'计划外')=0;
run;
data all3_2(rename=(VISIT=visit1));
	set all3;
	where find(visit,'计划外')>0;
run;
proc sql;
	create table all3_1v as select a.*,b.visit length=100,b.visitnum from all3_1 as a left join sdtm.sv as b on a.usubjid=b.usubjid and  a.visit1=b.visit;
quit;
proc sql;
	create table all3_2v as select a.*,b.visit length=100,b.visitnum from all3_2 as a left join sdtm.sv as b on a.usubjid=b.usubjid and input(a.QSDTC,yymmdd10.)=input(b.SVSTDTC,yymmdd10.) where find(b.visit,'计划外')>0;
quit;
data all4;
	set all3_1v all3_2v;
run;
data se;
        set sdtm.se;
        x=input(sestdtc,yymmdd10.);
        y=input(seendtc,yymmdd10.);
run;
proc sort data=se;by usubjid SESEQ;run;
data se1;
        set se;
        by usubjid seseq;
        if last.usubjid then y=input(seendtc,yymmdd10.)+1;
        if first.usubjid then x=input(sestdtc,yymmdd10.)-1;
run;
proc sql;
        create table allx as select a.*,b.epoch length=30 from all as a 
        left join se1 as b on a.usubjid=b.usubjid and .<b.x<=input(egdtc,yymmdd10.)<b.y
        ;
quit;

data b1 b2 b3(keep=name sex) b4(keep=name age height weight);
set sashelp.class;
if _n_<=10 then do;
	output b1;
	output b2;
end;
else do;
	output b3;
	output b4;
end;
run;
data all;
   length word $20;
   drop string;
   string=' The quick brown fox jumps over the lazy dog.   ';
   do until(word=' ');
      count+1;
      word=scan(string, count);
      output;
   end;
run;
data cm2;
	set data;
	ARRAY narray(12) $ 10 aenoa aenob aenoc aenod aenoe cmdescc mhnoa mhnob mhnoc mhnod mhnoe cmdescd;
	size = dim( narray );
   	do i = 1 to size - 1;
      do j = i + 1 to size;
         if narray( i ) = narray( j ) then narray( j ) = '';
/*         if narray( i ) > narray( j ) then*/
/*            do;*/
/*               ntemp = narray( i );*/
/*               narray( i ) = narray( j );*/
/*               narray( j ) = ntemp;*/
/*            end;*/
      end;
    end;
run;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值