good day expects
I have a text file that contains data that looks like below:-
But I want to convert the data into Sas dataset, used the below script
DATA F_FILES.MATURITY_INVEST;
LENGTH
'ACCOUNT NO|SERIAL|MATURITY D|OPE'n $ 47;
LABEL
'ACCOUNT NO|SERIAL|MATURITY D|OPE'n = "ACCOUNT NO|SERIAL|MATURITY D|OPENED DATE|CLOSED DATE";
FORMAT
'ACCOUNT NO|SERIAL|MATURITY D|OPE'n $CHAR47.;
INFORMAT
'ACCOUNT NO|SERIAL|MATURITY D|OPE'n $CHAR47.;
INFILE '/SAS/data/RiskDataManagement/data/NWOW/data/VBM/Data/MATURITY_INVEST.TXT'
LRECL=47
ENCODING="LATIN1"
TERMSTR=CRLF
DLM='7F'x
MISSOVER
DSD;
INPUT
'ACCOUNT NO|SERIAL|MATURITY D|OPE'n : $CHAR47.;
RUN;
please assist
Please post the sample data either in the code window or as a text file so that somebody can help.
Please post the sample data either in the code window or as a text file so that somebody can help.
Looks like you need this:
data f_filkes.maturity_invets;
infile
'/SAS/data/RiskDataManagement/data/NWOW/data/VBM/Data/MATURITY_INVEST.TXT'
dlm = '|'
dsd
truncover
firstobs=2
;
length
account_no $9
serial $3
maturity_d 4
opened_date 4
closed_date 4
;
informat maturity_d opened_date closed_date yymmdd10.;
format maturity_d opened_date closed_date yymmdd10.;
input
account_no
serial
maturity_d
opened_date
closed_date
;
run;
Untested; for tested code, supply the text in a code box opened with this button:
or attach the file.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.