<?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: Set a variable in data set in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645811#M22058</link>
    <description>Thanks, a lot !&lt;BR /&gt;I will remember your lessons sensei</description>
    <pubDate>Thu, 07 May 2020 09:35:33 GMT</pubDate>
    <dc:creator>boubou31</dc:creator>
    <dc:date>2020-05-07T09:35:33Z</dc:date>
    <item>
      <title>Set a variable in data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645806#M22056</link>
      <description>&lt;P&gt;Hey genius,&lt;BR /&gt;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.&lt;BR /&gt;I hope i've been clear, and thanks you for your help !&lt;/P&gt;&lt;PRE&gt;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(&amp;amp;temps_fin_mean.-&amp;amp;temps_debut_mean.),0.001);
522  %put Durée d’exécution moyenne : &amp;amp;duree_mean.;
Durée d’exécution moyenne : round( 0.10415411000576,0.001)
523  %let duree_median = round( %sysevalf(&amp;amp;temps_fin_median.-&amp;amp;temps_debut_median.),0.001);
524  %put Durée d’exécution medianne : &amp;amp;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  &amp;amp;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  &amp;amp;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;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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(&amp;amp;temps_fin_mean.-&amp;amp;temps_debut_mean.),0.001);
%put Durée d’exécution moyenne : &amp;amp;duree_mean.;
%let duree_median = round( %sysevalf(&amp;amp;temps_fin_median.-&amp;amp;temps_debut_median.),0.001);
%put Durée d’exécution medianne : &amp;amp;duree_median.;

/* DATA resultat; */
/* input datatype kind tailleMatrice reroll distrib drange operation implementation time; */
/* run; */
Data resultat;
input time;
datalines;
&amp;amp;duree_mean
&amp;amp;duree_median
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 May 2020 08:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645806#M22056</guid>
      <dc:creator>boubou31</dc:creator>
      <dc:date>2020-05-07T08:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set a variable in data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645810#M22057</link>
      <description>&lt;P&gt;Mistake #1 (don't worry, it happened to everyone of us): you can't use macro language and datalines together; no macro triggers (&amp;amp;,%)in datalines, and no datalines in macro definitions.&lt;/P&gt;
&lt;P&gt;Mistake #2: using the data step function ROUND in a %let without wrapping it in %sysfunc.&lt;/P&gt;
&lt;P&gt;Mistake #3: making your life unnecessarily complicated by involving macro processing where it is not needed.&lt;/P&gt;
&lt;P&gt;Do everything in the data step instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data resultat;
length step $10;
format duree time12.3;
step = "Mean";
duree = round(&amp;amp;temps_fin_mean. - &amp;amp;temps_debut_mean.,0.001);
ouput;
step = "Median";
duree = round(&amp;amp;temps_fin_median. - &amp;amp;temps_debut_median.,0.001);
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 May 2020 09:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645810#M22057</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-07T09:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Set a variable in data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645811#M22058</link>
      <description>Thanks, a lot !&lt;BR /&gt;I will remember your lessons sensei</description>
      <pubDate>Thu, 07 May 2020 09:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-a-variable-in-data-set/m-p/645811#M22058</guid>
      <dc:creator>boubou31</dc:creator>
      <dc:date>2020-05-07T09:35:33Z</dc:date>
    </item>
  </channel>
</rss>

