BookmarkSubscribeRSS Feed
leahstinson
Calcite | Level 5

having problem finding the issues with my code, no results showing in results tab

19 REPLIES 19
ballardw
Super User

First, on this forum it is best to paste Code or Log entries as TEXT in a text box. Copy the text from your editor or log window; on the forum open a text box using the </> icon above the message window and paste the text.

 

For a number of reasons many will not open attachments from unknown sources, such as you.

Second, you pasted a PICTURE of your code which makes it very hard to make changes to the code and I'm not going to retype a lot of text from a picture.

 

Did you read your LOG? Does your LOG show any errors? If not then it would show how many records were read into the data set.

 

Your code reads an external file into a data set using data step. That does not write anything to the results window unless you have a FILE PRINT statement and one or more PUT statements in the code.

 

If the data set was created successfully then you should be able to Proc Print the set to see the contents of the data set and that would be sent to the results window.

 

leahstinson
Calcite | Level 5

I can not copy and paste the text because it is a very log text and that w=is the reason my instructor told use to upload it into SAS. I also had to paste it to word because SAS would not allow me to upload images (pgn, ect..)

ballardw
Super User

@leahstinson wrote:

I can not copy and paste the text because it is a very log text and that w=is the reason my instructor told use to upload it into SAS. I also had to paste it to word because SAS would not allow me to upload images (pgn, ect..)


At the top of the message window is a row of icons. The 12th one from the left is a camera. If click on that a window appears that allows uploading windows by dragging them from another window, such as Windows explorer, and dropping them or click on the "choose files" and that should bring up your file manager so you can navigate to where the image file is kept on your computer.

 

The only way that your code could have generated a "long" text would be from invalid data messages, which would be about 100 lines or so and NOT that long. The details of those messages would tell use problems, such as reading incorrect variable types or informats.

 

The LOG is where the details of problems are, not the code. So sharing the log would have helped. It is still better to use TEXT because we can then copy and paste portions of the text, either to modify code or to provide how to interpret the information SAS is giving you.

leahstinson
Calcite | Level 5
libname leah'/home/u62178216/my_content' ;
data leah.Week5 ;
infile '/home/u62178216/my_content/Week5.txt' ;
input sexvar$ 1 genhlth$ 2 physhlth$ 3-4 medcost$ 5 diabage3 6-7 smoke$ 8
indortan$ 9-11 race$ 12 ;
label physhlth = 'How respondent rated their physical health' ;
run ;

 

that is my code so far. It is not showing any red errors, but it is showing messages.  

leahstinson
Calcite | Level 5
 
ballardw
Super User

LOST CARD almost always means you have attempted to read past the end of the actual data.

Since you are reading fixed columns and attempting to read the variable Race from column 12 any line of that external file that does not have 12 characters in the line encounters a problem.

leahstinson
Calcite | Level 5

This is my first SAS class and my instructor does not explain these issues, usually just gives us the data and we have to figure out the code and how to fix it. What is the best approach to fix this issue?

Kurt_Bremser
Super User

Open the text file with a text editor like Notepad (the freely available Notepad++ is better for this). Copy the first few lines and paste them into a window opened with this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

Tom
Super User Tom
Super User

Not sure what a "red error" is.  Are you perhaps talking about the color coding that some editors might do based on how the are guessing SAS will interpret the code?

 

You are missing a space in your libname statement between the libref (the name of the library you are defining) and the directory.  Does that generate an error in the LOG?

 

You also have the $ input modifier smashed up against the variable names as if it was part of the variable name.  That just looks confusing, but SAS can probably figure it out since the $ character cannot be part of a variable name.

 

If some of the lines do not have all 12 characters on them then you should add the TRUNCOVER option to the INFILE statement.  Note there are only very extremely rare situations where you would use the ancient MISSOVER option instead of the modern (only 30 years old) TRUNCOVER option.

 

Coding hint.  Indent the body of the DATA step. When you have multiple line statement, like your INPUT place the ending semi-colon on a new line, it will be easier to see where the statement ends without having to move your focus from the beginning of the lines.  Moving your focus (and/or your eyes or your head) back and forth can cause you to lose your place.

 

libname leah '/home/u62178216/my_content' ;
data leah.Week5 ;
  infile '/home/u62178216/my_content/Week5.txt'  truncover;
  input sexvar $ 1 genhlth $ 2 physhlth $ 3-4 medcost $ 5 diabage3 6-7 smoke $ 8 
      indortan $ 9-11 race $ 12 
  ;
  label physhlth = 'How respondent rated their physical health' ;
run ;

 

leahstinson
Calcite | Level 5

I do not have any red errors in my code.

here is it...

 

libname leah'/home/u62178216/my_content' ;
data leah.Week5 ;
infile '/home/u62178216/my_content/Week5.txt' ;
input sexvar$ 1 genhlth$ 2 physhlth$ 3-4 medcost$ 5 diabage3$ 6-7 smoke$ 8
indortan$ 9-11 race$ 12 ;
label physhlth = 'How respondent rated their physical health' ;
run ;

the only thing I am getting is this...

 

Tom
Super User Tom
Super User

Why do you keep attaching DOCX files?

 

leahstinson
Calcite | Level 5

So that you can see the screenshot of my SAS results. This is the notes that I am getting from my code.

Log 1.PNG

pictures 

Tom
Super User Tom
Super User

@leahstinson wrote:

So that you can see the screenshot of my SAS results. This is the notes that I am getting from my code.

Log 1.PNG

pictures 


Why do you include a photograph of text?

 

The most important part of the log you cropped out of the photo.

How many lines were read from the text file.

How long was the shortest line?

How long was the widest line?

 

Is there anything WRONG with the dataset that it generated?  Perhaps the LOST CARD was after the end of the actual data so that it does not matter.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 2614 views
  • 0 likes
  • 5 in conversation