Hey genius,
So i'm struggling here with several problem. I calculate the time of an proc to run, and now i want to write down my result in a file. But i'm already stuck with the fact of putting this variable in a DATA set. I thougn at the beginning it was cause my data was too long, so i try to apply a round, but it's look like the code ignore it. So at the end of this programm, i'm just having an empty table.
I hope i've been clear, and thanks you for your help !
1 %studio_hide_wrapper; 82 /* Generated Code (IMPORT) */ 83 /* Source File: integ_narr_1_norm_tiny_1.txt */ 84 /* Source Path: /Users/olivier.perruchet@gmail.com/Zebrys/integ_narr_1_norm_tiny_1.txt */ 85 /* Code generated on: May 5, 2020, 4:02:18 PM */ 86 proc sql; 87 %if %sysfunc(exist(WORK.IMPORT5)) %then %do; 88 drop table WORK.IMPORT5; NOTE: Table WORK.IMPORT5 has been dropped. 89 %end; 90 %if %sysfunc(exist(WORK.IMPORT5, VIEW)) %then %do; 91 drop view WORK.IMPORT5; 92 %end; 93 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 94 95 FILENAME REFFILE FILESRVC 96 FOLDERPATH='/Users/olivier.perruchet@gmail.com/Zebrys' 97 FILENAME='integ_narr_1_norm_tiny_1.txt'; 98 99 PROC IMPORT DATAFILE=REFFILE DBMS=CSV OUT=WORK.IMPORT5; 100 GETNAMES=no; 101 DATAROW=1; 102 RUN; NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to WORK.PARMS.PARMS.SLIST. 103 /********************************************************************** 104 * PRODUCT: SAS 105 * VERSION: V.03.05 106 * CREATOR: External File Interface 107 * DATE: 07MAY20 108 * DESC: Generated SAS Datastep Code 109 * TEMPLATE SOURCE: (None Specified.) 110 ***********************************************************************/ 111 data WORK.IMPORT5 ; 112 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ 113 infile REFFILE delimiter = ',' MISSOVER DSD lrecl=32767 ; 114 informat VAR1 best32. ; 115 informat VAR2 best32. ; 116 informat VAR3 best32. ; 117 informat VAR4 best32. ; 497 VAR127 498 VAR128 499 ; 500 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ 501 run; NOTE: The infile REFFILE is: Filename=integ_narr_1_norm_tiny_1.txt, URI path=/files/files/75628334-7975-46f3-89e3-f518dbb310e9, File Identifier=75628334-7975-46f3-89e3-f518dbb310e9, Content Type=application/octet-stream, Parent URI=/folders/folders/e423dd04-15c5-4803-b06a-6e9e2a4412b3, RECFM=V,LRECL=32767,File Size (bytes)=65536, Last Modified=05May2020:08:16:41, Create Time=05May2020:08:16:41 NOTE: 256 records were read from the infile REFFILE. The minimum record length was 255. The maximum record length was 255. NOTE: The data set WORK.IMPORT5 has 256 observations and 128 variables. NOTE: DATA statement used (Total process time): real time 0.09 seconds cpu time 0.03 seconds 256 rows created in WORK.IMPORT5 from REFFILE. NOTE: WORK.IMPORT5 data set was successfully created. NOTE: The data set WORK.IMPORT5 has 256 observations and 128 variables. NOTE: PROCEDURE IMPORT used (Total process time): real time 0.35 seconds cpu time 0.15 seconds 502 503 PROC CONTENTS DATA=WORK.IMPORT5; 504 RUN; NOTE: PROCEDURE CONTENTS used (Total process time): real time 0.11 seconds cpu time 0.16 seconds NOTE: The PROCEDURE CONTENTS printed pages 171-174. 505 506 507 508 509 %let temps_debut_mean = %sysfunc(time()); 510 511 proc means data=work.import5 mean; 512 run; NOTE: There were 256 observations read from the data set WORK.IMPORT5. NOTE: The PROCEDURE MEANS printed pages 175-177. NOTE: PROCEDURE MEANS used (Total process time): real time 0.10 seconds cpu time 0.12 seconds 513 514 %let temps_fin_mean = %sysfunc(time()); 515 %let temps_debut_median = %sysfunc(time()); 516 517 proc means data=work.import5 median; 518 run; NOTE: There were 256 observations read from the data set WORK.IMPORT5. NOTE: The PROCEDURE MEANS printed pages 178-180. NOTE: PROCEDURE MEANS used (Total process time): real time 0.12 seconds cpu time 0.13 seconds 519 520 %let temps_fin_median = %sysfunc(time()); 521 %let duree_mean = round( %sysevalf(&temps_fin_mean.-&temps_debut_mean.),0.001); 522 %put Durée d’exécution moyenne : &duree_mean.; Durée d’exécution moyenne : round( 0.10415411000576,0.001) 523 %let duree_median = round( %sysevalf(&temps_fin_median.-&temps_debut_median.),0.001); 524 %put Durée d’exécution medianne : &duree_median.; Durée d’exécution medianne : round( 0.125685930303,0.001) 525 526 /* DATA resultat; */ 527 /* input datatype kind tailleMatrice reroll distrib drange operation implementation time; */ 528 /* run; */ 529 Data resultat; 530 input time; 531 datalines; NOTE: Invalid data for time in line 532 1-11. RULE:----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 532 &duree_mean time=. _ERROR_=1 _N_=1 NOTE: Invalid data for time in line 533 1-13. RULE:----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 533 &duree_median time=. _ERROR_=1 _N_=2 NOTE: The data set WORK.RESULTAT has 2 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 534 ; 535 run; 536 537 538 539 540 541 %studio_hide_wrapper;
proc sql;
%if %sysfunc(exist(WORK.IMPORT5)) %then %do;
drop table WORK.IMPORT5;
%end;
%if %sysfunc(exist(WORK.IMPORT5, VIEW)) %then %do;
drop view WORK.IMPORT5;
%end;
quit;
FILENAME REFFILE FILESRVC
FOLDERPATH='/Users/olivier.perruchet@gmail.com/Zebrys'
FILENAME='integ_narr_1_norm_tiny_1.txt';
PROC IMPORT DATAFILE=REFFILE DBMS=CSV OUT=WORK.IMPORT5;
GETNAMES=no;
DATAROW=1;
RUN;
PROC CONTENTS DATA=WORK.IMPORT5;
RUN;
%let temps_debut_mean = %sysfunc(time());
proc means data=work.import5 mean;
run;
%let temps_fin_mean = %sysfunc(time());
%let temps_debut_median = %sysfunc(time());
proc means data=work.import5 median;
run;
%let temps_fin_median = %sysfunc(time());
%let duree_mean = round( %sysevalf(&temps_fin_mean.-&temps_debut_mean.),0.001);
%put Durée d’exécution moyenne : &duree_mean.;
%let duree_median = round( %sysevalf(&temps_fin_median.-&temps_debut_median.),0.001);
%put Durée d’exécution medianne : &duree_median.;
/* DATA resultat; */
/* input datatype kind tailleMatrice reroll distrib drange operation implementation time; */
/* run; */
Data resultat;
input time;
datalines;
&duree_mean
&duree_median
;
run;
Mistake #1 (don't worry, it happened to everyone of us): you can't use macro language and datalines together; no macro triggers (&,%)in datalines, and no datalines in macro definitions.
Mistake #2: using the data step function ROUND in a %let without wrapping it in %sysfunc.
Mistake #3: making your life unnecessarily complicated by involving macro processing where it is not needed.
Do everything in the data step instead:
data resultat;
length step $10;
format duree time12.3;
step = "Mean";
duree = round(&temps_fin_mean. - &temps_debut_mean.,0.001);
ouput;
step = "Median";
duree = round(&temps_fin_median. - &temps_debut_median.,0.001);
output;
run;
Mistake #1 (don't worry, it happened to everyone of us): you can't use macro language and datalines together; no macro triggers (&,%)in datalines, and no datalines in macro definitions.
Mistake #2: using the data step function ROUND in a %let without wrapping it in %sysfunc.
Mistake #3: making your life unnecessarily complicated by involving macro processing where it is not needed.
Do everything in the data step instead:
data resultat;
length step $10;
format duree time12.3;
step = "Mean";
duree = round(&temps_fin_mean. - &temps_debut_mean.,0.001);
ouput;
step = "Median";
duree = round(&temps_fin_median. - &temps_debut_median.,0.001);
output;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.