BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Q1.Using the procefure 'PROC CONTENTS'  to the SAS data set Fin_account' you can obtain an output data set containg the following data structure information (a) variable name (b)varable type (c)length (d)column lable

 

Q2. Applying the 'PROC SQL' on the output data set inn Q1. abve , to create a data set which can tell you how many character and numeric fields in the data set work.'Fin_account'.

 

Q3.Using the 'PROC CONTENTS' to send data dictionary of all data sets in the library work into a SAS TABLE 'alldata' using work.all-

option .The resulting table only keeps the following three fields 

a)variable name

b) variable type

c) libraray name

d) name of the table

 

Q4. Applying the 'PROC SQL' onn the output table in Q2 above to create a data set  which can tell you how many character and numeric fields in for each data set in the library ' WORK'

 

3 REPLIES 3
noling
SAS Employee

Are you asking 4 questions? Proc sql's dictionary.columns table can do this all in one place:

 

%let libname=SASHELP; *note UPPERCASE;
%let table=CARS; *note UPPERCASE;

*Q1;
proc sql noprint;
	create table q1(keep=name type length label) as
	select * from dictionary.COLUMNS
	where libname="&libname" and memname="&table";
quit; 

*Q2;
proc sql noprint;
	create table q2 as
	select count(*) as count, type from q1
	group by type;
quit; 

*Q3 (also keeping type for your Q4);
proc sql noprint;
	create table alldata(keep=name libname memname type) as
	select * from dictionary.COLUMNS
	where libname="WORK";
quit; 

*Q4 - I'm assuming you mean reference table from Q3, not Q2;
proc sql noprint;
	create table q4 as
	select memname, type, count(*) as count from alldata
	group by type, memname
	order by memname, type;
quit; 

Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

Kurt_Bremser
Super User

You should be able to do your homework yourself if you properly attended the lessons.

If you run into problems while trying, post example data, code and log.

ballardw
Super User

Hints: Q1 and Q3: option OUT=;

Hint: Q3 _all_

Hints Q2 Q4 : group by, count(*)

 

Or Read The Friendly Manual, i.e. online documentation for Proc Contents.

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
  • 498 views
  • 0 likes
  • 4 in conversation