BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Daily1
Quartz | Level 8

sas stored process create new variable sas code

PROC SQL;
CREATE TABLE DATA1  AS
SELECT

t1.HEAD,put(input(t1.HEAD,best4.),z4.) as HEAD1 

from data t1

quit;

 

ods markup file="//report/data.xls" tagset=tagsets.test alias='normal' style=mystyle;

 

proc report data=data;
run;

 

excel output not display and columns not display

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Use in below code the option to create and populate variable HEAD that fits your data the best.

It's just about applying the right format to the SAS variable so SAS can "tell" Excel how to represent the value.

data class;
  set sashelp.class;
  Age_c=put(age, 3.);
run;

PROC SQL;
  CREATE TABLE DATA1  AS
    SELECT
      t1.Name, 
      put(input(t1.Age_c,best4.),z4.) as HEAD1 format=$4.,
      input(t1.Age_c,best4.) as HEAD2 format=z4.,
      t1.age as HEAD3 format=z4.
    from class t1;
quit;

ods excel  file="c:\temp\data.xlsx";

proc report data=data1;
run;

ods excel close;

Patrick_0-1650432026330.png

 

View solution in original post

8 REPLIES 8
andreas_lds
Jade | Level 19

Read the log, or post it here so that we see what's happening actually.

Astounding
PROC Star
PROC REPORT is printing the wrong data set. The new variables are part of DATA1, not DATA.
Sajid01
Meteorite | Level 14

Hell @Daily1 
If your intention is to create an excel file, why not use ods excel instead of ods markup?

I am giving an example code approximating your code. Try this and it should work.

data class;
set sashelp.class;
Age_c=put(age, 3.);
run;
PROC SQL;
CREATE TABLE DATA1  AS
SELECT
t1.Name, put(input(t1.Age_c,best4.),z4.) as HEAD1 
from class t1;
quit;
ods excel  file="/home/theprogmin/data.xlsx" ;
proc report data=data1;
run;
ods excel close;

If this does not work, do  post the complete log as text - not as an image or screen shot.

Daily1
Quartz | Level 8
HEAD1 column records are not leading zeros like 0086 not dispaly in excel download in stored process
Patrick
Opal | Level 21

Use in below code the option to create and populate variable HEAD that fits your data the best.

It's just about applying the right format to the SAS variable so SAS can "tell" Excel how to represent the value.

data class;
  set sashelp.class;
  Age_c=put(age, 3.);
run;

PROC SQL;
  CREATE TABLE DATA1  AS
    SELECT
      t1.Name, 
      put(input(t1.Age_c,best4.),z4.) as HEAD1 format=$4.,
      input(t1.Age_c,best4.) as HEAD2 format=z4.,
      t1.age as HEAD3 format=z4.
    from class t1;
quit;

ods excel  file="c:\temp\data.xlsx";

proc report data=data1;
run;

ods excel close;

Patrick_0-1650432026330.png

 

Daily1
Quartz | Level 8
This code implement on sas code stored process manager but output this excel format is leading zero and new variable not display
Patrick
Opal | Level 21

@Daily1 

English is also not my native language but ... can you please re-formulate what you've trying to say because currently it's all gibberish to me.

Daily1
Quartz | Level 8

First create Stored process this code after excel output not show 

data class;
  set sashelp.class;
  Age_c=put(age, 3.);
run;

PROC SQL;
  CREATE TABLE DATA1  AS
    SELECT
      t1.Name, 
      put(input(t1.Age_c,best4.),z4.) as HEAD1 format=$4.,
      input(t1.Age_c,best4.) as HEAD2 format=z4.,
      t1.age as HEAD3 format=z4.
    from class t1;
quit;

ods excel  file="c:\temp\data.xlsx";

proc report data=data1;
run;

ods excel close;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 8 replies
  • 1778 views
  • 2 likes
  • 5 in conversation