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'
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
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.