SAS Restructure Data





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1















I need help restructuring the data. My Table looks like this



 NameHead Department Per_test Per_Delta Per_DB Per_Vul  
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79


And I want my table to look like this



NameHead    Nancy   Jim    Shu      Dick        Elena    Nancy   
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79


I tried proc transpose but couldnt get the desired result. Please help!



Thanks!










share|improve this question

























  • I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.

    – Tom
    Nov 23 '18 at 21:09











  • I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.

    – JCP
    Nov 23 '18 at 21:14











  • What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?

    – Tom
    Nov 23 '18 at 21:18




















-1















I need help restructuring the data. My Table looks like this



 NameHead Department Per_test Per_Delta Per_DB Per_Vul  
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79


And I want my table to look like this



NameHead    Nancy   Jim    Shu      Dick        Elena    Nancy   
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79


I tried proc transpose but couldnt get the desired result. Please help!



Thanks!










share|improve this question

























  • I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.

    – Tom
    Nov 23 '18 at 21:09











  • I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.

    – JCP
    Nov 23 '18 at 21:14











  • What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?

    – Tom
    Nov 23 '18 at 21:18
















-1












-1








-1








I need help restructuring the data. My Table looks like this



 NameHead Department Per_test Per_Delta Per_DB Per_Vul  
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79


And I want my table to look like this



NameHead    Nancy   Jim    Shu      Dick        Elena    Nancy   
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79


I tried proc transpose but couldnt get the desired result. Please help!



Thanks!










share|improve this question
















I need help restructuring the data. My Table looks like this



 NameHead Department Per_test Per_Delta Per_DB Per_Vul  
Nancy Health 55 33.2 33 63
Jim Air 25 22.8 23 11
Shu Water 26 88.3 44 12
Dick Electricity 77 55.9 66 10
Elena General 88 22 67 9
Nancy Internet 66 12 44 79


And I want my table to look like this



NameHead    Nancy   Jim    Shu      Dick        Elena    Nancy   
Department Health Air Water Electricity General Internet
Per_test 55 25 26 77 88 66
Per_Delta 33.2 22.8 88.3 55.9 22 12
PerDB 33 23 44 66 67 44
Per_Vul 63 11 12 10 9 79


I tried proc transpose but couldnt get the desired result. Please help!



Thanks!







sas transpose






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 21:10







JCP

















asked Nov 23 '18 at 20:46









JCPJCP

65




65













  • I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.

    – Tom
    Nov 23 '18 at 21:09











  • I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.

    – JCP
    Nov 23 '18 at 21:14











  • What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?

    – Tom
    Nov 23 '18 at 21:18





















  • I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.

    – Tom
    Nov 23 '18 at 21:09











  • I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.

    – JCP
    Nov 23 '18 at 21:14











  • What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?

    – Tom
    Nov 23 '18 at 21:18



















I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.

– Tom
Nov 23 '18 at 21:09





I assume that your first example has the variable names as the first row. What variable names do want for your result table? Your example does not show any.

– Tom
Nov 23 '18 at 21:09













I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.

– JCP
Nov 23 '18 at 21:14





I just edited the tables...hope it makes it clearer. I want the NameHead to be my first row.

– JCP
Nov 23 '18 at 21:14













What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?

– Tom
Nov 23 '18 at 21:18







What names do you want for the variables in your output dataset? Or do you just want a report? If a report what format do you want the report, PDF, RTF, Excel sheet, text file?

– Tom
Nov 23 '18 at 21:18














1 Answer
1






active

oldest

votes


















0














PROC TRANSPOSE does exactly what you want. You must include a VAR statement if you want to include the character variables.



proc transpose data=have out=want;
var _all_;
run;


Note that you cannot have variables that do not have names. Here is what the dataset looks like.



Obs _NAME_            COL1         COL2         COL3         COL4         COL5         COL6

1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79





share|improve this answer


























  • I actually want column names as NameHead ....sorry not the first row.

    – JCP
    Nov 23 '18 at 21:38













  • Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

    – Tom
    Nov 23 '18 at 21:49














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452767%2fsas-restructure-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














PROC TRANSPOSE does exactly what you want. You must include a VAR statement if you want to include the character variables.



proc transpose data=have out=want;
var _all_;
run;


Note that you cannot have variables that do not have names. Here is what the dataset looks like.



Obs _NAME_            COL1         COL2         COL3         COL4         COL5         COL6

1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79





share|improve this answer


























  • I actually want column names as NameHead ....sorry not the first row.

    – JCP
    Nov 23 '18 at 21:38













  • Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

    – Tom
    Nov 23 '18 at 21:49


















0














PROC TRANSPOSE does exactly what you want. You must include a VAR statement if you want to include the character variables.



proc transpose data=have out=want;
var _all_;
run;


Note that you cannot have variables that do not have names. Here is what the dataset looks like.



Obs _NAME_            COL1         COL2         COL3         COL4         COL5         COL6

1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79





share|improve this answer


























  • I actually want column names as NameHead ....sorry not the first row.

    – JCP
    Nov 23 '18 at 21:38













  • Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

    – Tom
    Nov 23 '18 at 21:49
















0












0








0







PROC TRANSPOSE does exactly what you want. You must include a VAR statement if you want to include the character variables.



proc transpose data=have out=want;
var _all_;
run;


Note that you cannot have variables that do not have names. Here is what the dataset looks like.



Obs _NAME_            COL1         COL2         COL3         COL4         COL5         COL6

1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79





share|improve this answer















PROC TRANSPOSE does exactly what you want. You must include a VAR statement if you want to include the character variables.



proc transpose data=have out=want;
var _all_;
run;


Note that you cannot have variables that do not have names. Here is what the dataset looks like.



Obs _NAME_            COL1         COL2         COL3         COL4         COL5         COL6

1 NameHead Nancy Jim Shu Dick Elena Nancy
2 Department Health Air Water Electricity General Internet
3 Percent_test 55 25 26 77 88 66
4 Percent_Delta 33.2 22.8 88.3 55.9 22 12
5 Percent_DB 33 23 44 66 67 44
6 Percent_Vul 63 11 12 10 9 79






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 21:26

























answered Nov 23 '18 at 21:16









TomTom

24.8k2720




24.8k2720













  • I actually want column names as NameHead ....sorry not the first row.

    – JCP
    Nov 23 '18 at 21:38













  • Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

    – Tom
    Nov 23 '18 at 21:49





















  • I actually want column names as NameHead ....sorry not the first row.

    – JCP
    Nov 23 '18 at 21:38













  • Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

    – Tom
    Nov 23 '18 at 21:49



















I actually want column names as NameHead ....sorry not the first row.

– JCP
Nov 23 '18 at 21:38







I actually want column names as NameHead ....sorry not the first row.

– JCP
Nov 23 '18 at 21:38















Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

– Tom
Nov 23 '18 at 21:49







Those are not "column names". They are the names of the variables that hold the data. Variables have to have names. NameHead is not the column header, it is the value of the first column and the first row. You can make a report that doesn't include the variable names if you want.

– Tom
Nov 23 '18 at 21:49






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452767%2fsas-restructure-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()