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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1404 views
  • 0 likes
  • 3 in conversation