sas proc

Not applicable
Posts: 0

sas proc

how we change a variable into observation
Super Contributor
Super Contributor
Posts: 3,176

Re: sas proc

Posted in reply to deleted_user
If I am correct with your post message, here is one approach to convert a SAS dataset having multiple variables into a new SAS dataset, each observation/value transposed to a separate data observation (using a single variable).

For a given SAS dataset, using a SAS DATA step approach, input the SAS file with a SET stmt, declare a SAS variable, either numeric or character, and using an ARRAY, assign each element in the array to the declared variable and issue an output to generate a separate observation.

Recommend using the SAS support and its SEARCH facility for SAS-host documentation and technical/conference papers.

Scott Barry
SBBWorks, Inc.

SAS Language Concepts: DATA Step Processing

A Hands-On Introduction to SAS® DATA Step Programming
Debbie Buck, D. B. & P. Associates, Houston, TX

* create some sample data to use with this exercise;
data temp;
input (x1-x5) ($);
x1 x2 x3 x4 x5
* convert a horizontal SAS dataset to vertical, one obs per variable/value combination. ;
data temp_vertical;
set temp;
array a_allvars (*) $ _all_;
* declare output var attribute
attrib x length=$2 label='transposed obs/var value';
do i=1 to dim(a_allvars);
x = a_allvars(i);
* putlog ">DIAG_INFO>" / _ALL_;
Not applicable
Posts: 0

Re: sas proc

Thanks a lot for this information
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation