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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1045 views
  • 2 likes
  • 5 in conversation