sorry about my data but why are you specifically doing for first 3 records and first 5 records
It not the first three (and five) records but, rather, the first three variables and the last five variables.
The code is changing the commas to semicolons for all fields except the fourth one, the one that can contain embedded commas.
Then it is simply reading the record, using semicolons as the delimiter and only expecting to possibly confront commas when reading the fourth field.
Thank you its gr8 function I ever came across thank you very much to learn about this
You may not have any control over the source of the CSV, but if you do and it comes out of Excel, you could request a tab delimited file as source instead. This is just as easy to produce from Excel, and can be read with the standard Proc Import in SAS. The advantages are: commas in the value are no longer a problem, no non standard code to maintain, and any additional columns which might be introduced into the data will be dealt with automatically.
I would also advocate use of the comma informat.
Richard
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.