BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lars45
Fluorite | Level 6

Hey SAS-Community,

 

i'm working on a programm which has to import periodical several csv-datas. My current solution looks like this:

 

%macro imp(infile);
PROC IMPORT datafile = "C:\Users\..."
OUT=work.&infile

 


DBMS=csv REPLACE;
DELIMITER = ';';

GETNAMES=YES;

datarow=2;

run;

Data work.&infile ;
 set work.&infile ;
 Reporting_month = Put(Today(),YYMMN6.);
run;

%mend imp;
%imp(System1_201909)
%imp(System2_201909)

 

So far, it works quite good. Now i'd like to change the "201909" of the macrovariables automatically to the acctual year and date. All my attemps were not successful, so far.

 

Thanks for your help!

 

Lars

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Lars45,

 

Do you mean this?

%imp(System1_%sysfunc(today(),yymmn6.))

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

Hi @Lars45,

 

Do you mean this?

%imp(System1_%sysfunc(today(),yymmn6.))
Lars45
Fluorite | Level 6
I did not expect the solution to be so simple^^

Thank you!
ballardw
Super User

Relying on Proc Import to read many files often leads to inconsistency between the variable types and lengths of character variables. As a minimum I would suggest that you add a GUESSINGROWS statement to the Proc Import code with a largish value. Better in the long run might be to write a proper data step to read that file so you can control all of the variable properties.

Tom
Super User Tom
Super User

If the text file only has two variables why are you using PROC IMPORT?

data want;
 infile 'myfile.txt' dsd dlm=';' truncover firstobs=2;
 input var1 var2;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 644 views
  • 3 likes
  • 4 in conversation