what is the difference between T sql and and Proc sqlSAS proc sql concatenation and join likeInsert Date Field to MS SQL from Proc SQLChanging SAS ODS contentitem for PROC SQL SELECT statementUsing PROC SQL in SAS to transpose a table from long to wideproc sql aggregateSAS conditional execution of proc sqlHash join equivalent on PROC SQL betweenDifference between SQLite and PROC SQL when evaluating blank spaceSAS (proc sql) count number of records if difference between two date variables greater of 3 yearsPROC SQL LEFT JOIN

How can ping know if my host is down

Multiplicative persistence

A Trivial Diagnosis

Giving feedback to someone without sounding prejudiced

Can I say "fingers" when referring to toes?

What is the English pronunciation of "pain au chocolat"?

Strong empirical falsification of quantum mechanics based on vacuum energy density?

Has any country ever had 2 former presidents in jail simultaneously?

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?

How to convince somebody that he is fit for something else, but not this job?

How could a planet have erratic days?

Why do ¬, ∀ and ∃ have the same precedence?

I found an audio circuit and I built it just fine, but I find it a bit too quiet. How do I amplify the output so that it is a bit louder?

How do I fix the group tension caused by my character stealing and possibly killing without provocation?

Is there a nicer/politer/more positive alternative for "negates"?

Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?

Does "he squandered his car on drink" sound natural?

Doesn't the system of the Supreme Court oppose justice?

"Oh no!" in Latin

Why is the Sun approximated as a black body at ~ 5800 K?

Can you use Vicious Mockery to win an argument or gain favours?

How to make money from a browser who sees 5 seconds into the future of any web page?

Is there a RAID 0 Equivalent for RAM?



what is the difference between T sql and and Proc sql


SAS proc sql concatenation and join likeInsert Date Field to MS SQL from Proc SQLChanging SAS ODS contentitem for PROC SQL SELECT statementUsing PROC SQL in SAS to transpose a table from long to wideproc sql aggregateSAS conditional execution of proc sqlHash join equivalent on PROC SQL betweenDifference between SQLite and PROC SQL when evaluating blank spaceSAS (proc sql) count number of records if difference between two date variables greater of 3 yearsPROC SQL LEFT JOIN













-1















Can someone please help me with solution?



sample1:



ReportMonthYear ProductItemCode ClosedDate PriorMonthCalendarDate
20160331 1234 24Mar2016 0:00:00 20160201


sample2:



ReportMonthYear ProductItemCode OpenDate ClosedDate OverDraftExpiryDate
20160229 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150930 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151130 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150731 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150831 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160131 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160331 1234 13Mar2015 0:00:00 24Mar2016 0:00:00
20151231 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151031 1234 13Mar2015 0:00:00 28Oct2016 0:00:00


I am getting correct results when I use T-SQL but not by Proc SQL.



output required:



ProductItemCode ReportMonthYear PriorMonthCalendarDate ClosedDate OverDraftExpiryDate earlyclosuremonths
1234 20160331 20160229 2016-03-24 00:00:00 28Oct2016 0:00:00 7


code in T sql:



select 
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthYear,
cd.ClosedDate,
df.OverDraftExpiryDate,
datediff(m,cd.ClosedDate,OverDraftExpiryDate) EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthYear = df.ReportMonthYear


code in Proc sql;



proc sql;
select
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthCalendarDate,
cd.ClosedDate,
df.OverDraftExpiryDate,
intck('month',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthCalendarDate = df.ReportMonthYear;
quit;









share|improve this question
























  • Why are you using a date interval for values that have datetime values?

    – Tom
    Mar 8 at 1:17











  • HI Tom, thank u for responding. I have considered date part only.sorry I forgot to take out time part. I tried but could not get answer. Can you please tell me how to get exact result?

    – Ramu
    Mar 9 at 6:17
















-1















Can someone please help me with solution?



sample1:



ReportMonthYear ProductItemCode ClosedDate PriorMonthCalendarDate
20160331 1234 24Mar2016 0:00:00 20160201


sample2:



ReportMonthYear ProductItemCode OpenDate ClosedDate OverDraftExpiryDate
20160229 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150930 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151130 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150731 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150831 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160131 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160331 1234 13Mar2015 0:00:00 24Mar2016 0:00:00
20151231 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151031 1234 13Mar2015 0:00:00 28Oct2016 0:00:00


I am getting correct results when I use T-SQL but not by Proc SQL.



output required:



ProductItemCode ReportMonthYear PriorMonthCalendarDate ClosedDate OverDraftExpiryDate earlyclosuremonths
1234 20160331 20160229 2016-03-24 00:00:00 28Oct2016 0:00:00 7


code in T sql:



select 
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthYear,
cd.ClosedDate,
df.OverDraftExpiryDate,
datediff(m,cd.ClosedDate,OverDraftExpiryDate) EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthYear = df.ReportMonthYear


code in Proc sql;



proc sql;
select
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthCalendarDate,
cd.ClosedDate,
df.OverDraftExpiryDate,
intck('month',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthCalendarDate = df.ReportMonthYear;
quit;









share|improve this question
























  • Why are you using a date interval for values that have datetime values?

    – Tom
    Mar 8 at 1:17











  • HI Tom, thank u for responding. I have considered date part only.sorry I forgot to take out time part. I tried but could not get answer. Can you please tell me how to get exact result?

    – Ramu
    Mar 9 at 6:17














-1












-1








-1








Can someone please help me with solution?



sample1:



ReportMonthYear ProductItemCode ClosedDate PriorMonthCalendarDate
20160331 1234 24Mar2016 0:00:00 20160201


sample2:



ReportMonthYear ProductItemCode OpenDate ClosedDate OverDraftExpiryDate
20160229 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150930 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151130 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150731 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150831 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160131 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160331 1234 13Mar2015 0:00:00 24Mar2016 0:00:00
20151231 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151031 1234 13Mar2015 0:00:00 28Oct2016 0:00:00


I am getting correct results when I use T-SQL but not by Proc SQL.



output required:



ProductItemCode ReportMonthYear PriorMonthCalendarDate ClosedDate OverDraftExpiryDate earlyclosuremonths
1234 20160331 20160229 2016-03-24 00:00:00 28Oct2016 0:00:00 7


code in T sql:



select 
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthYear,
cd.ClosedDate,
df.OverDraftExpiryDate,
datediff(m,cd.ClosedDate,OverDraftExpiryDate) EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthYear = df.ReportMonthYear


code in Proc sql;



proc sql;
select
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthCalendarDate,
cd.ClosedDate,
df.OverDraftExpiryDate,
intck('month',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthCalendarDate = df.ReportMonthYear;
quit;









share|improve this question
















Can someone please help me with solution?



sample1:



ReportMonthYear ProductItemCode ClosedDate PriorMonthCalendarDate
20160331 1234 24Mar2016 0:00:00 20160201


sample2:



ReportMonthYear ProductItemCode OpenDate ClosedDate OverDraftExpiryDate
20160229 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150930 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151130 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150731 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20150831 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160131 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20160331 1234 13Mar2015 0:00:00 24Mar2016 0:00:00
20151231 1234 13Mar2015 0:00:00 28Oct2016 0:00:00
20151031 1234 13Mar2015 0:00:00 28Oct2016 0:00:00


I am getting correct results when I use T-SQL but not by Proc SQL.



output required:



ProductItemCode ReportMonthYear PriorMonthCalendarDate ClosedDate OverDraftExpiryDate earlyclosuremonths
1234 20160331 20160229 2016-03-24 00:00:00 28Oct2016 0:00:00 7


code in T sql:



select 
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthYear,
cd.ClosedDate,
df.OverDraftExpiryDate,
datediff(m,cd.ClosedDate,OverDraftExpiryDate) EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthYear = df.ReportMonthYear


code in Proc sql;



proc sql;
select
cd.ProductItemCode,
cd.ReportMonthYear,
cd.PriorMonthCalendarDate,
cd.ClosedDate,
df.OverDraftExpiryDate,
intck('month',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths
from
sample1 cd
inner join sample2 df
on cd.ProductItemCode = df.ProductItemCode
and cd.PriorMonthCalendarDate = df.ReportMonthYear;
quit;






sas






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 1:16









Tom

24.3k2720




24.3k2720










asked Mar 8 at 0:03









RamuRamu

637




637












  • Why are you using a date interval for values that have datetime values?

    – Tom
    Mar 8 at 1:17











  • HI Tom, thank u for responding. I have considered date part only.sorry I forgot to take out time part. I tried but could not get answer. Can you please tell me how to get exact result?

    – Ramu
    Mar 9 at 6:17


















  • Why are you using a date interval for values that have datetime values?

    – Tom
    Mar 8 at 1:17











  • HI Tom, thank u for responding. I have considered date part only.sorry I forgot to take out time part. I tried but could not get answer. Can you please tell me how to get exact result?

    – Ramu
    Mar 9 at 6:17

















Why are you using a date interval for values that have datetime values?

– Tom
Mar 8 at 1:17





Why are you using a date interval for values that have datetime values?

– Tom
Mar 8 at 1:17













HI Tom, thank u for responding. I have considered date part only.sorry I forgot to take out time part. I tried but could not get answer. Can you please tell me how to get exact result?

– Ramu
Mar 9 at 6:17






HI Tom, thank u for responding. I have considered date part only.sorry I forgot to take out time part. I tried but could not get answer. Can you please tell me how to get exact result?

– Ramu
Mar 9 at 6:17













1 Answer
1






active

oldest

votes


















1














Looks like your "date" variables actually have datetime values instead date values. Dates are stored as the number of days since 1960 and datetimes are stored as the number of seconds instead.



If you calculate months on values that are in seconds instead of days you will get the wrong answer. Use the dtmonth interval instead.



intck('dtmonth',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths


Or convert your datetime values to dates and use the month interval.



intck('month',datepart(cd.ClosedDate),datepart(df.OverDraftExpiryDate)) as EarlyClosureMonths





share|improve this answer
























    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%2f55054781%2fwhat-is-the-difference-between-t-sql-and-and-proc-sql%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









    1














    Looks like your "date" variables actually have datetime values instead date values. Dates are stored as the number of days since 1960 and datetimes are stored as the number of seconds instead.



    If you calculate months on values that are in seconds instead of days you will get the wrong answer. Use the dtmonth interval instead.



    intck('dtmonth',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths


    Or convert your datetime values to dates and use the month interval.



    intck('month',datepart(cd.ClosedDate),datepart(df.OverDraftExpiryDate)) as EarlyClosureMonths





    share|improve this answer





























      1














      Looks like your "date" variables actually have datetime values instead date values. Dates are stored as the number of days since 1960 and datetimes are stored as the number of seconds instead.



      If you calculate months on values that are in seconds instead of days you will get the wrong answer. Use the dtmonth interval instead.



      intck('dtmonth',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths


      Or convert your datetime values to dates and use the month interval.



      intck('month',datepart(cd.ClosedDate),datepart(df.OverDraftExpiryDate)) as EarlyClosureMonths





      share|improve this answer



























        1












        1








        1







        Looks like your "date" variables actually have datetime values instead date values. Dates are stored as the number of days since 1960 and datetimes are stored as the number of seconds instead.



        If you calculate months on values that are in seconds instead of days you will get the wrong answer. Use the dtmonth interval instead.



        intck('dtmonth',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths


        Or convert your datetime values to dates and use the month interval.



        intck('month',datepart(cd.ClosedDate),datepart(df.OverDraftExpiryDate)) as EarlyClosureMonths





        share|improve this answer















        Looks like your "date" variables actually have datetime values instead date values. Dates are stored as the number of days since 1960 and datetimes are stored as the number of seconds instead.



        If you calculate months on values that are in seconds instead of days you will get the wrong answer. Use the dtmonth interval instead.



        intck('dtmonth',cd.ClosedDate,df.OverDraftExpiryDate) as EarlyClosureMonths


        Or convert your datetime values to dates and use the month interval.



        intck('month',datepart(cd.ClosedDate),datepart(df.OverDraftExpiryDate)) as EarlyClosureMonths






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 9 at 19:58

























        answered Mar 8 at 1:13









        TomTom

        24.3k2720




        24.3k2720





























            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%2f55054781%2fwhat-is-the-difference-between-t-sql-and-and-proc-sql%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







            Popular posts from this blog

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page