BookmarkSubscribeRSS Feed
sasuser123123
Quartz | Level 8

Hi everyone.

I have catalog contains 5 variables....AEACN,AETERM,AESTDY,AEBODSYS,AESEV and its description

So Im trying to create dataset from catalog  should contain values of 5 variables. when I run below program it gives only AEACN value.so my doubt is instead of giving one entry name what command should we use for getting all desciptions of varibles to a new dataset. Can anyone please help me out.

 

filename mycat catalog "mine.one.AEACN.SOURCE";

data aeacn;
infile mycat end=eof length=len;
input @1 Description $varying32767. len;
run;

14 REPLIES 14
sasuser123123
Quartz | Level 8

So can I use dataset name as entryname insteadd of AEACN

Kurt_Bremser
Super User

A catalog does NOT contain variables, datasets contain variables.

Catalogs contain entries of different types (source, format, macro, to name a few).

In your code, you are addressing a single entry of type SOURCE, and try to read it as a text file.

What do you intend to do with a dataset containing code in a character variable?

Please describe your intentions more clearly.

sasuser123123
Quartz | Level 8
#KurtBremser Yes that Catalog contains different entries (memname,type,format,name, source)
The name have AEACN, AEDECODE,AESTDY,AESEV...

When I ran above code it creates variable given in input statement and that variable contains description of AEACN....
(
ex..
Name Description
AEACN other action taken
)
If I ran program it would be value of description with new variable given in input statement..

Hope you understand my question..
Peter_C
Rhodochrosite | Level 12
It seems unlikely, but is @sasuser123123 trying to read all these source entries in one data step? Can I assume the names ( AEACN,AETERM,AESTDY,AEBODSYS,AESEV ) are each source entries? And that sasuser123123 wants contents of all streamed to a file?
I expect there are better ways to export selected catalogs entries a bit like the SOURCE Procedure would export from a program library in a pds on mvs and the BUILD Procedure would print selected catalog source entries (or all text orrc) to a text file.
For these environments we have constructed export solutions with SQL INTO : mVar separated by "syntax as needed" for the appropriate catalog entries from the sashelp.vcatalg dictionary table. I expect there are examples in the archives. So I'm not invented a new example for such uncertain definition of requirements
The original requirement is still unclear.
Tom
Super User Tom
Super User

Why the heck are you using source entries in catalogs?

Anyway just use the FILEVAR= option on the INFILE statement to control which member you want to read from the catalog.

First let's make some SOURCE entries in a catalog to have an example to work with.

data _null_;
  length memname $32 catalog $200 ;
  do memname='AEACN','AETERM','AESTDY' ;
    catalog=cats('work.somecat.',memname,'.SOURCE');
    file mycat catalog filevar=catalog ;
    put memname= ;
  end;
run;

Now we can use the same DO loop (or an input dataset if you want) to read all of those entries.

data all;
  length memname $32 catalog $200 ;
  do memname='AEACN','AETERM','AESTDY' ;
    catalog=cats('work.somecat.',memname,'.SOURCE');
    infile mycat catalog filevar=catalog length=len end=eof;
    do row=1 by 1 while(not eof);
      input @1 Description $varying32767. len;
      output;
    end;
  end;
  stop;
run;

Resullt:

Obs    memname    row     Description

 1     AEACN       1     memname=AEACN
 2     AETERM      1     memname=AETERM
 3     AESTDY      1     memname=AESTDY


Tom
Super User Tom
Super User

You can query DICTIONARY.CATALOGS (or SASHELP.VCATALG) to get the list of the source objects in a particular catalog.

So now you program can look something like this:

data all;
  set sashelp.vcatalg;
  where libname='WORK' and memname='SOMECAT' and objtype='SOURCE';
  length name $132 ;
  name = catx('.',libname,memname,objname,objtype);
  infile src catalog filevar=name end=eof;
  do line=1 by 1 while(not eof);
    input;
    description=_infile_;
    output;
  end;
run;
sasuser123123
Quartz | Level 8
#Tom But my expected result is not like that. In description it should have corresponding value of AEACN like
DESCRIPTION
Other action taken
Tom
Super User Tom
Super User

@sasuser123123 wrote:
#Tom But my expected result is not like that. In description it should have corresponding value of AEACN like
DESCRIPTION
Other action taken

How could I possibly re-create the contents of the binary SAS catalogs on your computer with an example program?

 

Are you sure you actually have SOURCE catalog entries that you want to read?  Your expected output just looks like a variable label, which is not something that would normally be stored in a source catalog.  Instead you could just get that from running proc content on the dataset that contains the AEACN variable.

sasuser123123
Quartz | Level 8
No actually it's not variable label it's variable (description) value present in catalog
Tom
Super User Tom
Super User

@sasuser123123 wrote:
No actually it's not variable label it's variable (description) value present in catalog

So run the code I posted on your catalog(s) and see what it reads.  If it does not look right then just open SAS's Display Manager and look at the source entries yourself and see what is in them.

sasuser123123
Quartz | Level 8
#Tom I ran that code so got output
Memname row Description
AEACN 1 memname=AEACN

but my intention is not like that it should be

Memname row Description
AEACN 1 other action taken


Tom
Super User Tom
Super User

You seem to have run the code I posted without adapting it to your situation. Including running the data step I had to CREATE some example SOURCE catalogs entries.

 

Modify the step I posted that READS from the catalog entries so that points to your LIBNAME and MEMNAME, not the catalog that my little example data step created.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 14 replies
  • 1511 views
  • 2 likes
  • 4 in conversation