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
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
@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.
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;
?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.