Can I include code in the SAS dataset?

Reply
Regular Contributor
Posts: 161

Can I include code in the SAS dataset?

Dear All:

Is it possible to include the code I use to generate the database within the database I just created?  I tend to forget how I produce the dataset in the first place.  Thank you -

Super User
Posts: 5,256

Re: Can I include code in the SAS dataset?

How big is your implementation, no users etc?

For larger sites, requirements like this is solved by meta data GUI tools, such as SAS DI Studio/Server.

What kind of code are you talking about, just creata tablas as... or whole programs with data transformations etc?

If your data-base is in SAS, char variables can be up to 32K, so it is possible to store somewhat large programs in SAS tables. But not very user friendly, since it would be hard to keep indentations, line breaks etc.

Perhaps it's easier to maintain a meta data table with the names of the programs for each database object, and then keep all programs in a central location.

Data never sleeps
Valued Guide
Posts: 3,208

Re: Can I include code in the SAS dataset?

Oops that is pre-historic question. In the old days of It requirments code and loggins were saved along the Develop/Test/Production process.

No matter of the all the toollings used a responsible person managed that. Do you have a dtap approach with life-cycle management, release management, change processes? 

---->-- ja karman --<-----
Regular Contributor
Posts: 161

Re: Can I include code in the SAS dataset?

Only user is me, but I make changes on the code over time, so I need a better version control or correspondence between code and data.  Right now my method is not to use permanent library at all and generate database as needed.  But this is time consuming because I need to do this every time I run my program.

But if I just create the dataset, I will forget how I created the database in the first place and which version of code I used.

I will explore Linus' suggestion.  Is there a software or package for this (not necessarily from SAS.).  Git?

Thanks -


Super User
Posts: 17,824

Re: Can I include code in the SAS dataset?

I think you need a better working system. Keeping code in a database isn't a solution.

You need to version your code/datasets somehow. Use GIT/CVS for version control or I just date things. Not a good system by any means, but I can't install software and I definitely can't allow my code to be in the cloud or online.

I also recommend, keeping a tracking system of your requests, basic request info, path to where the programs and output are for those files.

I've seen an excel file used, and I use SharePoint to build mine.

Regular Contributor
Posts: 161

Re: Can I include code in the SAS dataset?

Hi, Reeza:

Yes, I just created an Excel file to manage my code so that I don't have to re-do everything. Thanks -

Super User
Posts: 6,936

Re: Can I include code in the SAS dataset?

Put each iteration into its own directory (while the libname is limited to 8 characters, the physical path to the library is basically unlimited). Save the programs there, also, either as .sas files or members in a catalog. Then you can even easily archive each iteration in one step.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 5,256

Re: Can I include code in the SAS dataset?

Software package for what part of my suggestion?

Since you are a single user, I feel that a naming convention of your SAS program file should be sufficient, or jus a plain two column table with SAS table name and SAS program name.

If you want to version control, could be achieved by naming standard (version no in name), or make use of some content mgmt system (i.e. Sharepoint) or a specific source control mgmt - check with the IT department at your site if you anything in-house.

Data never sleeps
Regular Contributor
Posts: 161

Re: Can I include code in the SAS dataset?

Hi, LinusH:

I tried some fancy version control software mentioned in the SAS daily blog.  But those are too high-tech for my situation.  It seems that Excel would suffice. 

Respected Advisor
Posts: 4,646

Re: Can I include code in the SAS dataset?

There is a LABEL= dataset option but it is limited to 256 characters. You could save there a path to the SAS program that created the dataset.

PG

PG
Valued Guide
Posts: 3,208

Re: Can I include code in the SAS dataset?

Caveman you are: the developer, tester, acceptance , production user, operations production, change manager, release coordinator, business analyst  and doing all those roles as a single person.

It can be very confusing to choose a good approach for some question within those roles. Going into a meeting for that is giving little response.  (a little bit kidding)

I do not get your question well into these mentioned roles.

a- Is it the operational part having different group of users with slightly different requirements?

b- Is it the life-cyle process where must be able to underpin how you composed the delivered data (tables)l with the belonging used code?      

I disagree with Reeza that version-control will solve that. Version-control has the goal of coordinating changes made by many developers working on the same code in development stage.

When using Eclipse editor and going for eg java-sourced based projects having more than 10 programmers this a good approach. As Eguide is a IDE version control systems for code are somewhat like the hammer/nail/screw syndrome. The tool DI-studio is a programmers-tool that one known check-in check-out processes and for development has options to connect to SVN (apaches version management system).

When your question is option a.

Question: user-groups - different requirements typical all versions can be asked again

Solving: Ask your programmer (still you) if:

- it is possible to implement those little variations within the code activated by macro-setting or other parameter

- it is possible ta have a setup of code where those variations are isolated-sources code and the generic ones being used by all.   

    

When your question is option b.

Question: delivered - tables underpinning used code.

Solving: Ask release coordinator (still you) toe evaluate  options to:

1/ before releasing new code make a copy of all the existing code to a dedicated location related to that date/moment (arhvie off the release)

    When somebody knows the date of the delivered data also the used code can be delivered.

2/ Store the used code in the same location (this is possible with Windows/Unix) as the delivered data table(s)

    As *.sas and *.egp files can be stored on the OS as you like this will define a sure relationship.

    You can define filenames for easy access of the *.sas codes.

When you are using formats you also are having catalogs to be delivered along with the data/tables.

Catalogs are stored and maintained accessing as part of a libname. The same libname to be used as for tables.

You can store code into catalogs. SAS(R) 9.4 Statements: Reference, Second Edition (FILENAME Statement, CATALOG Access Method)

You can store code (source) log en output into catalogmembers using this filename accessmethod.

Then the answer for the original question "can I include SAS code into SAS datasets" is:  "Yes, uou can".  It could be part of catalog members along with the tables/datasets.     

---->-- ja karman --<-----
Super User
Posts: 17,824

Re: Can I include code in the SAS dataset?

Jaap Karman wrote:

I disagree with Reeza that version-control will solve that. Version-control has the goal of coordinating changes made by many developers working on the same code in development stage.

When using Eclipse editor and going for eg java-sourced based projects having more than 10 programmers this a good approach. As Eguide is a IDE version control systems for code are somewhat like the hammer/nail/screw syndrome. The tool DI-studio is a programmers-tool that one known check-in check-out processes and for development has options to connect to SVN (apaches version management system).

The programmer(s) you're working with is you from 3/6/9 months ago and you don't answer email.

Ask a Question
Discussion stats
  • 11 replies
  • 416 views
  • 6 likes
  • 6 in conversation