BookmarkSubscribeRSS Feed
Anoruo
Calcite | Level 5

Hello,

 

Please i intend to use the output from the proc freq procedure to execute the Proc Transpose  , however the Out=AA  dataset displays only the Country by Trt01p; So when i use the AA dataset to execute the Proc Transpose , the variables Sex , Race and Country are all missing .

 

Question : How do i make Sex, Race and Country appear in the AA dataset?

 

 

 

Proc freq data=B ;
Table SEX RACE ETHNIC COUNTRY / out=AA ;
BY Trt01p ;
Run;


/*Step 3*/

Proc Transpose data=AA ;
ID Trt01P ;
BY SEX RACE ETHNIC COUNTRY ;
VAR Count;
run;

 

I have attached the dataset 

 

Thanks a lot

4 REPLIES 4
Reeza
Super User

Try my example here:

https://gist.github.com/statgeek/e0903d269d4a71316a4e

 

If this is for display, you can also consider PROC TABULATE as an option. 

 


@Anoruo wrote:

Hello,

 

Please i intend to use the output from the proc freq procedure to execute the Proc Transpose  , however the Out=AA  dataset displays only the Country by Trt01p; So when i use the AA dataset to execute the Proc Transpose , the variables Sex , Race and Country are all missing .

 

Question : How do i make Sex, Race and Country appear in the AA dataset?

 

 

 

Proc freq data=B ;
Table SEX RACE ETHNIC COUNTRY / out=AA ;
BY Trt01p ;
Run;


/*Step 3*/

Proc Transpose data=AA ;
ID Trt01P ;
BY SEX RACE ETHNIC COUNTRY ;
VAR Count;
run;

 

I have attached the dataset 

 

Thanks a lot


 

Anoruo
Calcite | Level 5

@Reeza  Thanks for your response . It is not actually for display , i want to use it for some computations and i am required to use Proc Transpose. Thanks for your quick response.

Reeza
Super User

Did you run the code? It still answers your question.

 


@Anoruo wrote:

@Reeza  Thanks for your response . It is not actually for display , i want to use it for some computations and i am required to use Proc Transpose. Thanks for your quick response.


 

PGStats
Opal | Level 21

Maybe all you need is:

 


Proc freq data=B ;
Table SEX*RACE*ETHNIC*COUNTRY / out=AA ;
BY Trt01p ;
Run;

proc sort data=aa; by SEX RACE ETHNIC COUNTRY; run;

/*Step 3*/

Proc Transpose data=AA out=bb;
ID Trt01P ;
BY SEX RACE ETHNIC COUNTRY ;
VAR Count;
run;

?

PG

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1340 views
  • 0 likes
  • 3 in conversation