SAS Macros to Transpose Multiple Variables from Wide to Long and Long to Wide

The following SAS macros: are aimed at reshaping multiple variables in SAS. In SAS, the Data step and Procedure step can be used to transpose long format variables to wide format and vice versa but only few variables at a time.

Quite a few macros have been written to help with transposing several variables at a time but they are either difficult to use or voluminous.

In the current project, two SAS macros are written to transpose wide variables format to long variable formats when data are repeatedly measured on the same variables. The current macros are very simple and should be used with ease if the repeated variables follow a common pattern. After using the macros, the user may need to make minimum edits to remove unnecessary rows added.


 Is it gluten, fructan, or fructose sensitivity?

The number of people being diagnosed with gluten sensitivity is on the rise ( Leonard MM et al. 2017) but the food option is also increasing from time to time with almost all supermarkets with gluten free options of any popular food and restaurants with gluten free menus increasing. While gluten sensitivity (intolerance) may be the reason for most of the signs and symptoms commonly diagnosed as gluten sensitivity, fructan sensitivity, fructose sensitivity or fructose malabsorption maybe the actual culprit in some of the cases.

A recent study found that among 231 identified as non-celiac gluten sensitive patients  only 16%  actually responded to gluten challenge while 40% of those in the placebo group that took substances such as xylose, wey protein, corn starch containing fermentable carbohydrates experienced similar or increased symptoms (Molina-Infante J, and Carroccio A 2017).

What is gluten?

Gluten Exorphine B4

Gluten Exorphine B4

Gluten (C24H27N5O9)  is a protein that is found in foods such as wheat, barley, and  rye. It gets its name from Latin (gluten, which means glue) and it holds foods together to give foods their shape. In some people, the gastrointestinal system become sensitive to gluten and the body produces autoimmune antibodies  against gluten with immediate reaction but the antibodies also attack the intestinal micro-villi causing erosion of the villi and malabsorption resulting in systemic and local symptoms and signs including bloating, gas, abdominal cramp, constipation, and joint pains specially in celiac disease.

What is fructose?

Fructose is a  6-carbon monosaccharide carbohydrate commonly available in fruits and bonded to glucose to form sucrose a disaccharide sugar.

What is fructan?

Fructan is an oligosaccharide or polysaccharide carbohydrate which is a soluble dietary fiber found in onion, garlic, tomatoes, wheat,  barley, rye, asparagus, and chicory. Fructan is a polymer of fructose. It is one of the foods with high FODMAP (fermentable oligosaccharide, disaccharide, Monosaccharide and Polyols) according to Monash University that conducted an extensive study on highly fermentable foods that cause gas, bloating, abdominal pain, and diarrhea.

Is it gluten, fructose, or fructan intolerance/sensitivity?

Most foods that contain gluten also contain fructan which makes identifying the real culprit difficult. University of Oslo and Monash University researchers conducted a seven day randomized clinical trial where they administered bars containing gluten, fructan and placebo and measured symptom scores  using gastrointestinal symptom rating scale irritable bowel syndrome (GSRS-IBS) version (Skodje GI et al. 2017 ). They found a significantly different symptom scores with fructan showing the highest scores followed by gluten and the placebo showing the lowest symptom scores. Given that most gluten containing foods also contain fructan, it it is highly likely that the sensitivity is to fructan rather than to gluten at least in some of the cases. Both fructose, and fructan  are high FODMAP according to Monash University study.

High fructose corn syrup

How to identify whether a food contains gluten, fructose or fructan?

The best thing to do is to read the food ingredients before shopping them. Some foods may be marked gluten free but they may contain either fructose or fructan and it is worth paying attention to all the ingredients. This is specially true in cases of dressings that are often marked gluten-free but contain high fructose corn syrup. In addition, onions, garlic, and tomatoes are part and parcel of most foods and one needs to be aware that they are high FODMAPs. So, if you ate a gluten-free meal but still felt bad it is likely that the meal contained fructan or fructose.

There are gluten-free scanning  phone app and the  FODMAP app that can be used to help easily identify whether foods contain gluten, fructose or fructan. For the gluten-free scanning app, you just scan the bar-code of the item and it tells you whether the item is free of gluten  or it may contain ingredients that contain gluten. It is very easy to use. For the FODMAP app, it has a color-coded lists of foods identified as low, moderate and high FODMAP out of which you can select the low FODMAP foods and add to your shopping lists. In addition, it is wise to check the ingredients of dressings to make sure they do not contain high fructose corn syrup or fructan or substances with high FODMAP.

Contains fructan

So, are you gluten sensitive but still get symptoms after gluten-free meal? Next time, avoid onion, garlic, tomatoes, high-fructose corn syrup, and other foods with high FODMAP and check your symptoms in the next 3 to 4 hours.

High fructose corn syrup

Magnesium intake and incidence of pancreatic cancer: the VITamins and Lifestyle study

Daniel Dibaba, Pengcheng Xun, Kuninobu Yokota, Emily White,and Ka He

Received 26 June 2015; Revised 28 September 2015; Accepted 8 October 2015
Advance online publication 10 November 2015


Background: Method: Result: Conclusions: Materials and Methods Results Discussion Key messages Conflict of interest References Acknowledgements Figures and Tables


Studies document that magnesium is inversely associated with the risk of diabetes, which is a risk factor of pancreatic cancer. However, studies on the direct association of magnesium with pancreatic cancer are few and findings are inconclusive. In this study, we aimed to investigate the longitudinal association between magnesium intake and pancreatic cancer incidence in a large prospective cohort study.

A cohort of 66 806 men and women aged 50–76 years at baseline who participated in the VITamins And Lifestyle (VITAL) study was followed from 2000 to 2008. Multivariable-adjusted Cox regression models were used to estimate hazard ratios (HRs) and 95% confidence intervals (CIs) of pancreatic cancer incidence by magnesium intake categories.

During an average of 6.8-year follow-up, 151 participants developed pancreatic cancer. Compared with those who met the recommended dietary allowance (RDA) for magnesium intake, the multivariable-adjusted HRs (95% CIs) for pancreatic cancer were 1.42 (0.91, 2.21) for those with magnesium intake in the range of 75–99% RDA and 1.76 (1.04, 2.96) for those with magnesium intake <75% RDA. Every 100 mg per day decrement in magnesium intake was associated with a 24% increase in the incidence of pancreatic cancer (HR: 1.24; 95% CI: 1.02, 1.50; Ptrend=0.03). The observed inverse associations appeared not to be appreciably modified by age, gender, body mass index, and non-steroidal anti-inflammatory drug use but appeared to be limited to those taking magnesium supplementation (from multivitamins or individual supplement).

Findings from this prospective cohort study indicate that magnesium intake may be beneficial in terms of primary prevention of pancreatic cancer.


Magnesium intake; pancreatic cancer; VITAL study; prospective cohort

British Journal of Cancer (BJC)

The effect of magnesium supplementation on blood pressure in individuals with insulin resistance, prediabetes, or noncommunicable chronic diseases: a meta-analysis of randomized controlled trials.


Background: To our knowledge, the effect of magnesium supplementation on blood pressure (BP) in individuals with preclinical or noncommunicable diseases has not been previously investigated in a meta-analysis, and the findings from randomized controlled trials (RCTs) have been inconsistent.

Objective: We sought to determine the pooled effect of magnesium supplementation on BP in participants with preclinical or noncommunicable diseases.

Design: We identified RCTs that were published in English before May 2017 that examined the effect of magnesium supplementation on BP in individuals with preclinical or noncommunicable diseases through PubMed, ScienceDirect, Cochrane,, SpringerLink, and Google Scholar databases as well as the reference lists from identified relevant articles. Random- and fixed-effects models were used to estimate the pooled standardized mean differences (SMDs) with 95% CIs in changes in BP from baseline to the end of the trial in both systolic blood pressure (SBP) and diastolic blood pressure (DBP) between the magnesium-supplementation group and the control group.

Results: Eleven RCTs that included 543 participants with follow-up periods that ranged from 1 to 6 mo (mean: 3.6 mo) were included in this meta-analysis. The dose of elemental magnesium that was used in the trials ranged from 365 to 450 mg/d. All studies reported BP at baseline and the end of the trial. The weighted overall effects indicated that the magnesium-supplementation group had a significantly greater reduction in both SBP (SMD: -0.20; 95% CI: -0.37, -0.03) and DBP (SMD: -0.27; 95% CI: -0.52, -0.03) than did the control group. Magnesium supplementation resulted in a mean reduction of 4.18 mm Hg in SBP and 2.27 mm Hg in DBP.

Conclusion: The pooled results suggest that magnesium supplementation significantly lowers BP in individuals with insulin resistance, prediabetes, or other noncommunicable chronic diseases.