BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
YannRC
Quartz | Level 8

Hi, i am on Viya 4 and I only use flow in data studio. 

My question is that one : My IT department put a csv file with the same name at the beginning but with a date after. For example : 

 

> Sample20260224.csv for yesterday

> Sample20260225.csv for today

 

On my flow, I must have always the same name for the csv file. Can you confirm it? Or can it be possible to import a file like that sample*.csv?

1 ACCEPTED SOLUTION

Accepted Solutions
YannRC
Quartz | Level 8

Thanks a lot. I find how to do. 

View solution in original post

5 REPLIES 5
ChrisHemedinger
Community Manager

Hi,

 

You can import using a wildcard spec as you want, but you do need to write DATA step code for this. I don't think the Import Data step in SAS Studio does it for you. And PROC IMPORT does not support the wildcard format.

 

The INFILE statement, or FILENAME statement, can accept a wildcard. You can also designate a data set variable to store the name of the file as you read these.

 

filename csvs "/home/imports/sample*.csv";
data allfiles;
  length casefile $ 100 /* to write name of file to data set */
     counter 8 
     timestamp 8 
     x 8 y 8 z 8      
     csvfile $ 100 /* to hold the value */	       
   ;
 
   /* store the name of the current infile */       
   infile csvs filename=csvfile 
    dlm=',' ; 
  casefile=csvfile;
  input counter timestamp x y z;	
run;

 
See more explanation and examples here.

Become an Explorer! Join SAS Analytics Explorers to learn and complete challenges that earn rewards!
YannRC
Quartz | Level 8
 
I have this error. I don't really understand why because my file exist 
 
1    /* region: Pré-code généré */
2    /* Assurez-vous que le répertoire en cours est accessible en écriture */
3    data _null_;
4        length rc 4;
5        %let tworkloc="%sysfunc(getoption(work))";
6        rc=dlgcdir(&tworkloc);
7    run;
NOTE: The current working directory is now
      "/opt/sas/viya/config/var/tmp/compsrv/default/317dcf96-3228-43e1-9431-7deb0b8d8ff0/SAS_work439500000166_sas-compute-server-e37
      f3d33-d131-41f0-b9a1-a1b2f4e31416-8ntfl".
NOTE: DATA statement used (Total process time):
      real time           0.00 secondes
      cpu time            0.00 secondes
     
8    
9    /* Configurer les options */
10   title;
11   footnote;
12   options validvarname=any;
13   options validmemname=extend;
14   options dtreset date number;
15   options device=png;
16  
17   /* Configurer les macro-variables */
18   %let syscc=0;
19   %let _clientapp = %nrquote(%nrstr(SAS Studio));
20   %let _clientappabbrev = %nrquote(%nrstr(Studio));
21   %let _clientappversion=2025.09;
22   %let _clientversion=;
23   %let _sasservername=&SYSHOSTNAME;
24   %let _sashostname=&SYSHOSTNAME;
25   %let _sasprogramfilehost=&SYSHOSTNAME;
26   %let _clientuserid = %nrquote(%nrstr(yradenac@relaiscolis.com));
27   %let _clientusername = %nrquote(%nrstr(Yann RADENAC));
28   %let clientmachine = %nrquote(%nrstr());
29   %let _clientmachine = %nrquote(%nrstr());
30   %let _clientmode = %nrquote(%nrstr(viya));
31   %let sasworklocation="%sysfunc(getoption(work))/";
32   filename _cwd &sasworklocation;
33   data _null_;
34       call symput('_sasworkingdir',pathname('_cwd'));
35   run;
NOTE: DATA statement used (Total process time):
      real time           0.00 secondes
      cpu time            0.00 secondes
     
36   filename _cwd;
NOTE: Fileref _CWD has been deassigned.
37   %let _sasprogramfile = %nrquote(%nrstr());
38   %let _baseurl = %nrquote(%nrstr(https://relais-colis.ptc-hms.cloud/SASStudio));
39   %let _execenv = %nrquote(%nrstr(SASStudio));
40   %symdel _dataout_mime_type _dataout_name _dataout_url _dataout_table / nowarn;
41   %let _sasws_ = %bquote(%sysfunc(getoption(work)));
42   %let _saswstemp_ = %bquote(%sysfunc(getoption(work)));
43  
44   /* Détecter SAS/Graph et configurer les options graphiques */
45   data _null_;
46       length rc $255;
47       call symput("graphinit","");
48       call symput("graphterm","");
49       rc=tslvl('sasxgopt','n');
50       _error_=0;
51       if (rc^=' ') then do;
52           call symput("graphinit","goptions reset=all gsfname=_gsfname;");
53           call symput("graphterm","goptions noaccessible;");
54       end;
55   run;
NOTE: DATA statement used (Total process time):
      real time           0.00 secondes
      cpu time            0.00 secondes
     
56   data _null_;
57       length rc 4;
58       rc=sysprod("PRODNUM002");
59       if (rc^=1) then do;
60           call symput("graphinit","");
61           call symput("graphterm","");
62       end;
63   run;
NOTE: DATA statement used (Total process time):
      real time           0.00 secondes
      cpu time            0.00 secondes
     
64  
65   /* Configurer les destinations ODS */
66   ods _all_ close;
67   %studio_results_directory;
68   filename _htmlout "&_results_prefix_..html";
69   filename _listout "&_results_prefix_..lst";
70   filename _gsfname temp;
71   filename _dataout "&_results_prefix_..dat";
72   ods autonavigate off;
73   ods graphics on;
74   ods html5 (id=web) METATEXT='http-equiv="Content-Security-Policy" content="default-src ''none''; style-src ''unsafe-inline'';
74 ! img-src data: ;"' device=png gpath="&_saswstemp_" path="&_saswstemp_" encoding=utf8 file=_htmlout (title='Résultats :Étape
74 ! personnalisée 1.step') style=Light2025 options(bitmap_mode='inline' outline='on' svg_mode='inline'
74 ! css_prefix=".ods_&SYS_COMPUTE_JOB_ID" body_id="div_&SYS_COMPUTE_JOB_ID" );
NOTE: Writing HTML5(WEB) Body file: _HTMLOUT
75   ods listing file=_listout;
76   &graphinit;
77   %studio_initialize_custom_output;
78   /* endregion */
79  
80   /* region: Initialisation de la macro générée */
81  
82   /* Définir des macros utilitaires - DÉBUT */
83  
84   /* Macro pour obtenir une liste de noms de colonnes */
85   %macro _flw_get_column_list(_flw_prefix = %nrstr(), _delim=%str( ));
86      %do _flw_index=1 %to %unquote(&&&_flw_prefix._count);%unquote(&&&_flw_prefix._&_flw_index._name)%if
86 ! &_flw_index.<%unquote(&&&_flw_prefix._count)%then&_delim.; %end;
87   %mend;
88  
89   /* Macro pour supprimer les macro-variables avec les noms transmis */
90   %macro _flw_del_macro_vars(_flw_macro_vars_to_delete,_flw_no_warn=Y);
91      %if "&_flw_no_warn"="Y" %then %symdel &_flw_macro_vars_to_delete/NOWARN;
92      %else %symdel &_flw_macro_vars_to_delete;
93   %mend;
94  
95   /* Macro pour supprimer une liste de macros avec les noms transmis */
96   %macro _flw_del_macros(_flw_macro_names,_flw_no_warn=Y);
97      %let num=1;
98      %let _flw_local_macros_to_delete=%scan(&_flw_macro_names,&num);
99      %do %while (&_flw_local_macros_to_delete ne );
100        %if "&_flw_no_warn"="Y" %then %sysmacdelete &_flw_local_macros_to_delete/NOWARN;
101        %else %sysmacdelete &_flw_local_macros_to_delete;
102        %let num=%eval(&num+1);
103        %let _flw_local_macros_to_delete=%scan(&_flw_macro_names,&num);
104     %end;
105  %mend;
106  
107  /* Définir des macros utilitaires - FIN */
108  
109  /* Macro-variables dérivées de la saisie utilisateur jusqu’à cette étape - DÉBUT */
110  
111  /* Macro-variables dérivées de la saisie utilisateur jusqu’à cette étape - FIN */
112  
113  /* endregion */
114  /* Code SAS fourni dans la section template de l’étape personnalisée - DÉBUT */
115  filename csvs "G:\2_Data\Import_data\Recap_EDI*.csv";
116  data allfiles;
117    length casefile $ 100 /* to write name of file to data set */
118       counter 8
119       timestamp 8
120       x 8 y 8 z 8
121       csvfile $ 100 /* to hold the value */
122     ;
123  
124     /* store the name of the current infile */
125     infile csvs filename=csvfile
126      dlm=',' ;
127    casefile=csvfile;
128    input counter timestamp x y z;
129  run;
ERROR: Physical file does not exist,
       /opt/sas/viya/config/var/tmp/compsrv/default/317dcf96-3228-43e1-9431-7deb0b8d8ff0/SAS_work439500000166_sas-compute-server-e37
       f3d33-d131-41f0-b9a1-a1b2f4e31416-8ntfl/G:\2_Data\Import_data\Recap_EDI*.csv.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.ALLFILES may be incomplete.  When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.ALLFILES was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 secondes
      cpu time            0.00 secondes
     
130  
131  /* Code SAS fourni dans la section template de l’étape personnalisée - FIN */
132  
133  /* region: Nettoyage de la macro générée */
134  
135  /* Nettoyage des macros et des variables macro - DÉBUT */
136  /* Supprimer les macro-variables créées dans cette étape */
137  
138  /* Supprimer les macros définies dans cette étape */
139  %_flw_del_macros(_flw_get_column_list _flw_del_macro_vars);
140  
141  /* Nettoyage des macros et des variables macro - FIN */
142  
143  %sysmacdelete _flw_del_macros;
144  
145  /* endregion */
146  /* region: Post-code généré */
147  /* Récupération des erreurs */
148  %studio_error_recovery;
149  /* Fermer les destinations ODS */
150  &graphterm; ;*';*";*/;run;quit;
151  quit;run;
152  ods html5 (id=web) close;
153  ods listing close;
154  %if %sysfunc(fileref(_gsfname)) lt 0 %then %do;
155      filename _gsfname clear;
NOTE: Fileref _GSFNAME has been deassigned.
156  %end;
157  %studio_capture_custom_output;
158  /* endregion */
159  
Kurt_Bremser
Super User

Your SAS session runs on a remote UNIX-based server. It cannot access files stored on your local Windows system. Before you can read data from a file, you need to make it accessible, either by uploading to the server, or storing it on a shared resource which is also mapped on the UNIX server. In both cases, you need to use UNIX-style filename syntax. UNIX does not use drive letters and backslashes.

Talk to your SAS admins for assistance.

Tom
Super User Tom
Super User

Not sure about DATA Studio but in normal SAS/Studio you should be able to write code that uses macro logic to generate the name of the file to read.

 

If these files always follow the same pattern then do NOT use PROC IMPORT (or some data wizard) to read them.  Instead write a data step so the output dataset is always the same.

 

%let today=%sysfunc(today(),yymmddn10.);
data want;
  infile "...&today..csv" dsd truncover firstobs=2;
  ....
run;
YannRC
Quartz | Level 8

Thanks a lot. I find how to do. 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 470 views
  • 0 likes
  • 4 in conversation