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

Assuming dataset table1 has field1, how can I use proc contents inside proc report? Or is there any way to display all the columns of the dataset without actually specifying the field names?

PROC REPORT data=table1 nowd split='\' nocenter;
COLUMN
(
proc contents data = table1 varnum short;
 run;

)
by fieldname1;
TITLE1 "Comparison";
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You don't specify any, defaults are an awesome thing.

 

proc sort data=sashelp.class out=class;
by sex;

proc report data=class;
by sex;
run;

If you don't specify any, it defaults to all variables, similar to PROC REPORT. 


@bhu wrote:

Assuming dataset table1 has field1, how can I use proc contents inside proc report? Or is there any way to display all the columns of the dataset without actually specifying the field names?

PROC REPORT data=table1 nowd split='\' nocenter;
COLUMN
(
proc contents data = table1 varnum short;
 run;

)
by fieldname1;
TITLE1 "Comparison";
RUN;


 

View solution in original post

3 REPLIES 3
bhu
Obsidian | Level 7 bhu
Obsidian | Level 7
This helped me:

proc sql noprint;
select name into :var_list separated by " " from sashelp.vcolumn where libname="WORK" and memname="TABLE1";
quit;
PROC REPORT data=table1 nowd split='\' nocenter;
COLUMN
&var_list.;
by fieldname1;
TITLE1 "Comparison";
RUN;
Reeza
Super User

You don't specify any, defaults are an awesome thing.

 

proc sort data=sashelp.class out=class;
by sex;

proc report data=class;
by sex;
run;

If you don't specify any, it defaults to all variables, similar to PROC REPORT. 


@bhu wrote:

Assuming dataset table1 has field1, how can I use proc contents inside proc report? Or is there any way to display all the columns of the dataset without actually specifying the field names?

PROC REPORT data=table1 nowd split='\' nocenter;
COLUMN
(
proc contents data = table1 varnum short;
 run;

)
by fieldname1;
TITLE1 "Comparison";
RUN;


 

bhu
Obsidian | Level 7 bhu
Obsidian | Level 7

Awesome Reeza. Thank you a lot for such an easy solution. I have changed the accepted solution to your reply.

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!

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.

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
  • 3 replies
  • 1222 views
  • 1 like
  • 2 in conversation