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

PROC CONTENTS has an OUT= option to ouput a dataset with variable attributes. type=1 is numeric and type=2 is character.  how to make it show as Num or Char instead of 1 or 2 in vars dataset?

   proc contents data=sashelp.class out=vars;
   run;

   proc print data=vars noobs;
     var varnum name type length;
   run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Define a format.

proc format;
value type 1='num' 2='char';
run;
proc print data=vars noobs;
  var varnum name type length format label;
  format type type.;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Hi @magicdj  Switch to using Dictionary tables-


proc sql;
  create table vars_new as
  select *
  from dictionary.columns
  where libname = 'SASHELP' and memname = 'CLASS' ;
quit ;
Library Name Member Name Member Type Column Name Column Type Column Length Column Position Column Number
in Table
Column Label Column Format Column Informat Column Index Type Order in Key
Sequence
Extended Type Not NULL? Precision Scale Transcoded?
SASHELP CLASS DATA Name char 8 24 1         0 char no 0 . yes
SASHELP CLASS DATA Sex char 1 32 2         0 char no 0 . yes
SASHELP CLASS DATA Age num 8 0 3         0 num no 0 . yes
SASHELP CLASS DATA Height num 8 8 4         0 num no 0 . yes
SASHELP CLASS DATA Weight num 8 16 5         0 num no 0 . yes
Tom
Super User Tom
Super User

Define a format.

proc format;
value type 1='num' 2='char';
run;
proc print data=vars noobs;
  var varnum name type length format label;
  format type type.;
run;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 731 views
  • 0 likes
  • 3 in conversation