BookmarkSubscribeRSS Feed
jc3992
Pyrite | Level 9
%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;

Error page SAS.pngThe file"music"is what we were assigned to run with the codes provided.The file"music"is what we were assigned to run with the codes provided.

5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi, the code you posted in the log does not correspond to the code you got from the instructor. Please note that your code that shows the error message has "data=music;"

This is incorrect. For a DATA statement, there is NOT an = sign.

Next, your instructor's code has the keyword INFILE. Your LOG only shows FILE=. This is also incorrect. While there is a FILE= option, it is not the correct way to point to a file like a CSV file. Your instructor's code, showing the keword as INFILE, is correct.

My suggestion is that you try the code again, as it was given to you and see whether that works better.

cynthia
jc3992
Pyrite | Level 9
Hi Cynthia,
 
Thank you very much for your reply and help. Because when I typed the code from my instructor, the system did not show a blue colored word, so I though there might be some problems so I did not use them.
My lap top is Mac so I was kinda concerned if the codes from my professor works for my SAS studio. I will try it.
However I also do not understand the line as the attached code.
infile "&dirLSB.Bands.csv" DLM = ',' DSD MISSOVER /*termstr=CRLF*/; 
 
Thank you very much!
 
Sincerely 
Kurt_Bremser
Super User
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.

jc3992
Pyrite | Level 9

This is very useful to me. Thank you for providing these information and kindly spending time for my questions. Thanks!

Tom
Super User Tom
Super User

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.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1161 views
  • 4 likes
  • 4 in conversation