BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
gwwp
Obsidian | Level 7

I am using SAS Studio, and am unable to get output in results when running proc means for vars age broken down by r1surveyyear. Here is my code, which is based on the class lecture:

 

*import data and create temp dataset work.Assignment1;
PROC IMPORT DATAFILE='/home/u61957777/my_data.csv'
	DBMS=CSV
	replace
	OUT=Assignment1;
	GETNAMES=YES;
	
RUN;

*assign data to dataset dt1;
data dt1;
	set work.Assignment1;
	run;

*Replicate mean and standard deviation of age by survey period;

proc means data=dt1 mean; *no change for work.dt1, Assignment1 or work.Assignment1;
	var age;	
	class r1surveyyear;
run;

After run, there is no output in the results tab, and the log ends at the line for *replicate mean and standard deviation of age.

 

What am I missing here to get the output in results?

 

I am also having problems with what appear to be server-related errors, but the response in my question indicates that this has nothing to do with the lack of output in results.

 

1 ACCEPTED SOLUTION

Accepted Solutions
gwwp
Obsidian | Level 7

As suggested by @Reeza and @ballardw, it worked after changing the two-line comment

/*Replicate mean and standard deviation of age for parcipants in study years 
“1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

to

/*mean and standard deviation of age for study years “1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

I'm guessing that it has something to do with the comment being split over two lines, but it would be helpful to know if there are best practices for comments in SAS.

View solution in original post

22 REPLIES 22
PaigeMiller
Diamond | Level 26

Please look at the LOG yourself and see what problems appear in the LOG.

 

If that doesn't help, show us the entire LOG (that's every single line, every single character, do not chop parts out)

 

Copy the LOG as text, and paste it into the window that appears when you click on the </> icon.

Insert Log Icon in SAS Communities.png

--
Paige Miller
ballardw
Super User

LOG.

 

LOGS describe what SAS attempted and often provides the details that simple code doesn't such as missing data sets.

So, copy the LOG text and paste that into a text box.

 

Sometimes odd characters end up outside the visible part of the editor, especially when copy/pasting from other locations. If one of those characters is exactly the wrong one then you can have submission problems. If the code does not appear in the log then something along these lines might be involved and is going to be very hard to see as we do not have your system and the entire visible contents of your editor.

 

I have also seen a few odd things when using statement style comments, those that look like * some commented text; especially when actual code involves macros.

As a long shot I might suggest use of the /* comment text */  instead. DO not nest these inside each other.

gwwp
Obsidian | Level 7

My log is attached here for the following code:

/*import data and create temp dataset work.Assignment1*/
PROC IMPORT DATAFILE='/home/u61857737/my_data.csv'
	DBMS=CSV
	replace
	OUT=Assignment1;
	GETNAMES=YES;
	
RUN;

/*assign data to dataset dt1*/
data dt1;
	set work.Assignment1;
	run;

/*Exercise 1.1*/
/*Replicate mean and standard deviation of age for parcipants in study years “1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

proc means data=work.dt1 mean; /*no change for dt1, Assignment1 or work.Assignment1*/
	var age;	
run;
Reeza
Super User

I posted part of the answer on your previous post - the smart quotes are part of the issue.

 

Your log doesn't show any of the proc means being submitted at all or the comments so that's not the full log for the code.

 

A clean session is after you restart SAS so any issues from previous sessions are cleared out.

gwwp
Obsidian | Level 7

As suggested by @Reeza and @ballardw, it worked after changing the two-line comment

/*Replicate mean and standard deviation of age for parcipants in study years 
“1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

to

/*mean and standard deviation of age for study years “1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

I'm guessing that it has something to do with the comment being split over two lines, but it would be helpful to know if there are best practices for comments in SAS.

ballardw
Super User

@gwwp wrote:

As suggested by @Reeza and @ballardw, it worked after changing the two-line comment

/*Replicate mean and standard deviation of age for parcipants in study years 
“1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

to

/*mean and standard deviation of age for study years “1999-2004”, “2005-2010” and “2011-2014” in Table 1*/

I'm guessing that it has something to do with the comment being split over two lines, but it would be helpful to know if there are best practices for comments in SAS.


Since that comment includes "smart quotes", the curly left/right pairs, that appears to have been copied from another document of some sort, probably word processor. Which might mean that other formatting but not-visible characters were included where the line broke. Then by making it a single line you may have removed the not-visible to humans but read by the SAS code processor that were causing a problem.

 

There are 3 forms of comments in SAS:

*  ;

/*   */

%*   ;   (macro quotes)

Since the /* */ work pretty much everywhere, including in the middle of statements such as

 

Proc print data=something;
    var thisvar thatvar /* commentoutvar */ other var andyetanother;
run;

 

which means the variable commentoutvar is not included in the print output (at least for this trial).

Or surrounding an entire block of code statements:

/* Proc anyproc data=someset; statement one; statement two; statement three; run; */prevents that entire proc from submission.

I tend to only use the /*   */.

Caution: Do not nest comments.

/* start of comment

/* start of another comment */

end of first comment */

will cause all sorts of oddness and depending on code in/around it can be quite problematic.

Kurt_Bremser
Super User

Comments can be safely split over lines, both "statement comments" (* .... 😉 and "block comments" (/* ... */).

 

But you have to always be careful with properly terminating things:

Procedures with RUN or QUIT

Statements with semicolons

Comments

Macros with %MEND

Macro and function calls, and array references with a proper bracket

Strings with the proper quotes

 

especially when submitting parts of code.

PaigeMiller
Diamond | Level 26

@gwwp please mark the comment from either @Reeza or @ballardw as correct, and not your own reply that states the comment from those individuals was correct.

--
Paige Miller
gwwp
Obsidian | Level 7

How do I do that? There's no obvious way to change the solution. Previously the answers were not specific enough to be useful to other people with the same problem, but Ballard has now posted a more detailed answer which will work.

Reeza
Super User

This is also a really good example of why it's important to post code exactly as you ran it. That code doesn't show up like that anywhere in your post. I copied your code and ran it on Studio and had no issues, because the posted code didn't match the actual code.

Reeza
Super User

The issue is not the split lines it's something else - most likely an invisible character in your data line somewhere from copying and pasting. There's no issues with having comments on multiple lines. 

 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         
 70         /*assign data to dataset dt1*/
 71         data dt1;
 72         set sashelp.class;
 73         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.DT1 has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              684.53k
       OS Memory           25764.00k
       Timestamp           07/21/2022 03:11:13 PM
       Step Count                        24  Switch Count  2
       Page Faults                       0
       Page Reclaims                     167
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 74         
 75         /*Exercise 1.1*/
 76         /*Replicate mean and standard devia
 77         tion of age for parcipants in study years “1999-2004”, “2005-2010” and “2011-2014” in Table 1*/
 78         
 79         proc means data=work.dt1 mean; /*no change for dt1, Assignment1 or work.Assignment1*/
 80         var age;
 81         run;
 
 NOTE: There were 19 observations read from the data set WORK.DT1.
 NOTE: PROCEDURE MEANS used (Total process time):
       real time           0.01 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              7536.56k
       OS Memory           32712.00k
       Timestamp           07/21/2022 03:11:13 PM
       Step Count                        25  Switch Count  0
       Page Faults                       0
       Page Reclaims                     2167
       Page Swaps                        0
       Voluntary Context Switches        14
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 82         
 83         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 93         
Reeza
Super User

Restart SAS and run the code I posted. If it works then the problem is in your code.

 

If it doesn't then the problem is your settings/SAS installation.

Kurt_Bremser
Super User

The first statement in your log.txt should suppress all statements and messages, but it doesn't. And all subsequent statements are also not executed. But the first code after a comment is executed. This means that at the moment you submitted your code, a comment block was "active", because you submitted a comment without the closing */ before that.

Restart your SAS session and make sure all comments are properly terminated; if you submit partial code, make sure that comment blocks are included completely.

Tom
Super User Tom
Super User

How large is the dataset?

How many levels does the CLASS variable r1surveyyear have?

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 22 replies
  • 1479 views
  • 5 likes
  • 6 in conversation