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

Hi, This should be an easy one. I am trying to run proc contents as written below...

 

/*Count of sterilization failures by type by diagnosis*/

data deliveries;
set 'H:Deliveries\pcori_preg_diag_final.sas7bdat';
run;

proc contents;
deliveries;
run;

 

And I am getting this error message: 

4 proc contents;
NOTE: Writing HTML Body file: sashtml.htm
5 deliveries;
----------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
6 run;

 

What am I missing?

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

There is no need to make a copy of your data first before asking PROC CONTENTS (or any other proc) to use it.

proc contents data='H:\deliveries\pcori_preg_diag_final.sas7bdat';
run;

Remember to start your paths with \ or else Windows will treat them as relative, even when prefixed with a drive letter.

View solution in original post

11 REPLIES 11
mcgannmary1
Obsidian | Level 7
I have no idea how that smiley face showed up in my code!
PaigeMiller
Diamond | Level 26

@mcgannmary1 wrote:
I have no idea how that smiley face showed up in my code!

when pasting or typing SAS code, you need to first click on the running man icon and then type or paste your code into that window. Then the forum software will format the text as actual SAS code, and the colon followed by right-parenthesis (or colon follow by letter D, etc.) will not be intrepreted as a smiley face.

--
Paige Miller
mcgannmary1
Obsidian | Level 7

Thank you!

 

Reeza
Super User
You're missing the data= statement on your proc freq, the same thing you did with your PROC CONTENTS. For a proc to know what data set you're working with you should always put an explicit DATA= after the PROC name. If you don't, it uses the last generated file - not in the order of the program but what you ran, so it's very easy to get errors and wrong results when you don't use the DATA= on your PROC STATEMENTS. Especially at the beginning.
PaigeMiller
Diamond | Level 26
proc contents data=deliveries;
run;
--
Paige Miller
Reeza
Super User

It's not common to see the full path in your SET statement. It's more usual to see a libname referenced and then youcopy the data set over to use.

libname source 'H:\Deliveries\';
data deliveries;
set source.pcori_preg_diag_final;
run;

proc contents data=deliveries;
run;
Tom
Super User Tom
Super User

There is no need to make a copy of your data first before asking PROC CONTENTS (or any other proc) to use it.

proc contents data='H:\deliveries\pcori_preg_diag_final.sas7bdat';
run;

Remember to start your paths with \ or else Windows will treat them as relative, even when prefixed with a drive letter.

mcgannmary1
Obsidian | Level 7

Thank you for your speedy reply.

The code you shared worked!:)

 

mcgannmary1
Obsidian | Level 7
Hmmmm....the proc freq still doesn't work. Is there something wrong with the data step?

105 /*proc contents data='H:\PCORI\Deliveries\pcori_preg_diag_final.sas7bdat';*/
106 /*run; */
107
108 proc freq;
109 category;
--------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
110 run;

PaigeMiller
Diamond | Level 26

@mcgannmary1 wrote:


108 proc freq;
109 category;
--------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
110 run;


It's not clear what you are trying to do here in PROC FREQ, as there is no such thing as a CATEGORY statement in PROC FREQ.

 

Since this is independent of your earlier problem with PROC CONTENTS, you probably ought to start a new thread on this, rather than discuss it here.

--
Paige Miller
Tom
Super User Tom
Super User

Most procs will support the DATA= option on the PROC statement. But when in doubt look at the documentation for the PROC.

For PROC FREQ you need to use a TABLES statement to list of variables (or variable combinations) that you want to analyze.

proc freq data=deliveries;
  tables category;
run;

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 11 replies
  • 1662 views
  • 0 likes
  • 4 in conversation