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
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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.