%let dirLSB='/folders/myfolders/';
data=music;
file= '&dirdata.Bands2_Plus.csv' DLM= ',' dsd missover termstr=CRLF;
length Band_name$ 30 Gig_date$ 10;
input Band_name$ Gig_date$ Eight_PM Nine_PM Ten_PM Eleven_PM;
run;
infile "&dirLSB.Bands.csv" DLM = ',' DSD MISSOVER /*termstr=CRLF*/;
infile "&dirLSB.Bands.csv" DLM = ',' DSD MISSOVER /*termstr=CRLF*/;
This is an infile statement. It specifies a non-SAS file that is to be read by the data step.
The name of the file (including the whole path) is supplied as a character literal enclosed by double quotes. The double quotes are important, because they allow SAS to resolve macro triggers included in the string.
So this
&dirLSB.
is replace by the contents of macro variable &dirLSB
Note that the dot serves to terminate the name of the macro variable, and is removed by resolving this.
So the statement will look like this after the macro variable is resolved:
infile "/folders/myfolders/Bands.csv" DLM = ',' DSD MISSOVER /*termstr=CRLF*/;
DLM= specifies a delimiter used to separate columns.
DSD specifies two things: strings in quotes can include a delimiter that will not be used as such, and multiple delimiters will be interpreted as missing values in between.
MISSOVER means that if a data line does not have columns for all variables in the INPUT statement, the remaining variables will be set to missing (otherwise SAS would skip to the next line and try to satisfy the variables from there)
The final part is commented out (enclosed in /* and */), and would set an option for the string that signals the end of the line in the text file. If you have DOS(Windows) data, you might want to remove the comment, so that the option becomes active. UNIX uses a single LF character for the linefeed in text files, and SAS UE runs on a Linux system inside the virtual machine.
This is very useful to me. Thank you for providing these information and kindly spending time for my questions. Thanks!
The code at the top of your post has a problem (or two), but the code you ran in your SAS log has introduced even more problems.
Fix those problems and then let us know if you can figure out the error in the first program you posted.
Note there is no need to post photographs or screen captures of program code or SAS logs (or any other text strings). Just copy the text itself and use the {i} icon to pop-up a code window that you can paste the text into.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.