Write and run SAS programs in your web browser

Failed to run the code assigned at the class(green words are instructions from the teacher)

Reply
Contributor
Posts: 24

Failed to run the code assigned at the class(green words are instructions from the teacher)

%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.

Highlighted
SAS Super FREQ
Posts: 9,039

Re: Failed to run the code assigned at the class(green words are instructions from the teacher)

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
Contributor
Posts: 24

Re: Failed to run the code assigned at the class(green words are instructions from the teacher)

Posted in reply to Cynthia_sas
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 
Super User
Posts: 8,590

Re: Failed to run the code assigned at the class(green words are instructions from the teacher)

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 24

Re: Failed to run the code assigned at the class(green words are instructions from the teacher)

Posted in reply to KurtBremser

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

Super User
Super User
Posts: 7,402

Re: Failed to run the code assigned at the class(green words are instructions from the teacher)

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.

 

Ask a Question
Discussion stats
  • 5 replies
  • 143 views
  • 4 likes
  • 4 in conversation