BookmarkSubscribeRSS Feed
nm2542
Calcite | Level 5

When using the %MAKEWIDE macro code to transform a long form dataset into a wide form dataset, is there a macro code to retain the variable labels?

 

I’ve searched for codes but I can’t find any. When I use %MAKEWIDE command to transform long form dataset into wide form data set, the labels always disappear. Below is the code I use to sort and merge datasets into one complete wide form dataset. Is there a code I can add to ensure the variable labels carryover into the wide form dataset?

 

 

proc sort data=; by folio visit; run;

proc sort data=; by folio visit; run;

 

 

data /*data*/

            merge /* a b c...*/;

            by folio visit;

run;

 

 

/********************* TRANSFORM ******************************/

%include "J: SAS commands\transpose to wide_macro code.sas";

proc contents data=; run;

proc sort data=; by folio; run;

%MAKEWIDE (

DATA= data_old,

OUT=data_new,

ID=folio,

VAR=/*variables*/,

TIME=visit)

;

 

1 REPLY 1
Reeza
Super User

That's a custom user written macro, so you're best off contacting the author:

http://www.sascommunity.org/wiki/Transpose_data_with_macro_%25MAKEWIDE_and_%25MAKELONG_(based_on_Pro...)

 

Alternatively if you're using PROC TRANSPOSE you can use IDLABEL or you can try the macro here:

http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset

 


@nm2542 wrote:

When using the %MAKEWIDE macro code to transform a long form dataset into a wide form dataset, is there a macro code to retain the variable labels?

 

I’ve searched for codes but I can’t find any. When I use %MAKEWIDE command to transform long form dataset into wide form data set, the labels always disappear. Below is the code I use to sort and merge datasets into one complete wide form dataset. Is there a code I can add to ensure the variable labels carryover into the wide form dataset?

 

 

proc sort data=; by folio visit; run;

proc sort data=; by folio visit; run;

 

 

data /*data*/

            merge /* a b c...*/;

            by folio visit;

run;

 

 

/********************* TRANSFORM ******************************/

%include "J: SAS commands\transpose to wide_macro code.sas";

proc contents data=; run;

proc sort data=; by folio; run;

%MAKEWIDE (

DATA= data_old,

OUT=data_new,

ID=folio,

VAR=/*variables*/,

TIME=visit)

;

 


 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1 reply
  • 1086 views
  • 0 likes
  • 2 in conversation